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"
...
}