Been messing around with this. I have a project that has several modules and several build variants. For me, the key was to set each variant (except release
) to be debuggable in its modules' build.gradle
file:
buildTypes {
debug {
minifyEnabled false
debuggable true // THIS
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
...
}
After that, no matter what build variant I had selected the preview would show.
This is on Android Studio Electric Eel | 2022.1.1 Patch 1
project build.gradle
plugins {
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
...
}
app build.gradle
android {
...
composeOptions {
kotlinCompilerExtensionVersion '1.4.3'
}
...
}
dependencies {
...
implementation "androidx.compose.ui:ui-tooling-preview:1.3.3"
debugImplementation "androidx.compose.ui:ui-tooling:1.3.3"
...
}
#compose
channel, previews will not work until you can upgrade to Arctic Fox RC1, which unfortunately is not available yet. 😞 That same comment suggested that you could drop the tooling dependencies back tobeta09
and they would work withrc01
for the main dependencies. Note that I have not tried that yet, so I do not know if it would work.