I am working on updating an Android app using Android Studio 3. The previous versions where created using Android Studio 2.
When I build the last version using Android Studio 2 two separate APKs have been created, one for each product flavor I configured. Now in Android Studio 3 the "Generate Signed APK" dialog only offers a "combined" flavor which creates a single APK containing both flavors:
App Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.MyApp"
minSdkVersion 14
targetSdkVersion 26
versionCode 42
versionName "2.0.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "freemium", "free"
productFlavors {
MyApp {
dimension "freemium"
}
MyAppFree {
dimension "free"
applicationId 'com.example.MyApp.Free'
}
}
}
app-MyApp-MyAppFree-release.apk
is created instead of app-MyApp-release.apk
and app-MyAppFree-release.apk
How to fix this?
Ok, the problem was caused by using different flavor dimension s for the two flavors. Gradle creates one assemble task for each dimension combination: MyAppMyAppFree
in my case
I added the dimensions only to to silence the warning "All flavors must now belong to a named flavor dimension" when updating from Android Studio 2 to 3. Since I did not actually used the dimensions the solution was to simply use one dimension for both flavors:
flavorDimensions "default"
productFlavors {
MyApp {
dimension "default"
}
MyAppFree {
dimension "default"
applicationId 'com.example.MyApp.Free'
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.