I've been trying to build different product flavours to allow multiple side-by-side installs for our QA teams so I changed the applicationId to be different in each one.
buildTypes {
debug {
applicationId = "com.mypackagename.qa"
....
}
release {
applicationId = "com.mypackagename"
....
}
development {
applicationId = "com.mypackagename.development
....
}
}
However when I attempt to install them all, the release version is installed alone but both the development and the debug end up replacing each other.
Any thoughts on how to get them to install side by side?
Try to add versionNameSuffix. This is how it should look like:
buildTypes {
debug {
versionNameSuffix ".dev"
applicationIdSuffix '.dev'
}
iqa {
versionNameSuffix ".IQA"
debuggable true
signingConfig signingConfigs.debug
applicationIdSuffix '.IQA'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Related
I have this structure:
1: https://i.stack.imgur.com/zrt1u.png
With gradle:
signingConfigs {
release {
//release stuff
}
debug {
//debug stuff
}
}
flavorDimensions "version"
productFlavors {
pro {
dimension "version"
}
lite {
dimension "version"
applicationIdSuffix ".lite"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
applicationIdSuffix ".debug"
debuggable true
signingConfig signingConfigs.debug
}
}
I have buildTypes release and debug (I need those for using server testing environment) and 2 Flavors, for Pro user and Lite users.
Everything is working fine and as expected, but I encountered some problem then trying to add different menu folder for release buildType and noticed that some res folder not recognized by the IDE as res folder. For example proDebug folder is with stripes icon recognized as res, but liteDebug are not, why is this?
Found the answer, it depends on the current selected Build Variant in the IDE
I am not able to build beta version APK of my android app. I tried below code
buildTypes {
beta {
applicationIdSuffix ".beta"
versionNameSuffix "-beta"
resValue "string", "appname", "Beta App"
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "default"
productFlavors {
free{
applicationId "com.packagename.free"
}
paid{
applicationId "com.packagename.paid"
}
}
When I try to generate APK from Genrate Signed APK button, it show error -
com.packagename.free not found
In my app, I am using payu SDK. Please help. Thanks in Advance
You have to below things to build different variants of APK.
Change you app build.gradle like
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "string", "content_provider", "com.packagename.fileProvider"
}
staging {
signingConfig signingConfigs.release
applicationIdSuffix = ".debugStaging"
}
dexOptions {
matchingFallbacks = ['release', 'staging']
}
}
Now in open you payu build.gradle and add this line in side buildType
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
staging {
}
}
Now you have to create folder under main folder with the same name you gave in buildType "staging"
Now create a new directory inside -main->staging->java and then add your package inside java - com.packagename.debugStaging
debugStaging is same as added in staging applicationIdSuffix.
Now repeat step 3 and 4 for your pay SDK
folder under main directory with same name as "staging" and under this add java folder and payu package name
Final step- add your beta/staging app with packagename to firebase and download google-services.json file.
Hope this will help you.
I have introduced two product flavors and a new build type.
However when I run the Staging variant, it still tries to connect to the React Native Metro bundler. I want Staging to adopt the same steps as the Release build type.
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
debug {
debuggable true
}
staging {
initWith release
matchingFallbacks = ['release']
applicationIdSuffix ".beta"
debuggable true
signingConfig signingConfigs.release
}
}
productFlavors {
// Production
prodFlavor {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
dimension "builds"
}
// Staging
stagedFlavor {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
dimension "builds"
}
}
I am building this through CircleCI by running ./gradlew assembleStagedFlavorStaging. The apk builds fine but when I run it on my device I get the following
I am able to see this due to enabling debuggable. Without this line, the app crashes.
I am completely new to Product Flavors and I have gone through many links to understand it. But there are few doubts which are still not clear. I am having 3 product flavors i.e: qa, dev and prod. I have only created these three product flavors because I need to change the URLs and some API keys for different flavors which I have done by creating 3 different packages and placing the same java(having the URLs) file in the app/src directory. This is how my build.gradle. What are the mandatory things I need to add in each flavor? Something related to: proguard, signingConfigs:
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 26
buildToolsVersion '26.0.2'
flavorDimensions "default"
defaultConfig {
applicationId "com.sagar.demo"
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true
versionCode 67
versionName "1.0.0" //Update Version build number
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
signingConfigs {
release {
storeFile file("myKeystore")
storePassword "Keystore2017"
keyAlias "SagarSuri"
keyPassword "Keystore2020"
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false // shrink
useProguard false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
debuggable false
minifyEnabled true
useProguard true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
productFlavors {
qa {
dimension "default"
}
prod {
dimension "default"
signingConfig signingConfigs.release
}
dev {
dimension "default"
}
}
}
The way product flavors work is such that you'll end up with the number flavors in each dimension multiplied by the number of buildTypes, in your case you have 3 flavors in a single dimension and 2 build types which ends up with 3x2=6 build variants which are the following:
qaDebug
qaRelease
prodDebug
prodRelease
devDebug
devRelease
Each combination is an actual combination of the related product flavor config and the related build type config combined. Meaning for variant qaDebug, it's configuration are from the defined under qa and from the defined under debug combined. Hence if debug already defines the proguardFiles there's generally no need to define it in qa, unless if qa requires extra proguard configs for it's own code then that's a different matter that needs to be decided and hence proguard should be defined specific for each flavor and not in the build types.
Another aspect I'd like to point out is signingConfig which here is defined the same value for prod and release. This means that any combination that starts with prod or ends with Release will have the signingConfig set, which in this case are: qaRelease, prodDebug, prodRelease and devRelease.
Hence the configuration is really up to your choice and design, and not all projects will have the same config.
i have this build config in my gradle file ?
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix ".debug"
}
qa {
applicationIdSuffix ".qa"
versionNameSuffix ".qa"
}
}
sourceSets { debug { res.srcDirs = ['src/debug/res', 'src/debug/res/values'] } }
}
why when i am try to run qa it trow me and error for not having key for this flavor ?
The only build type for which Gradle can build your project "out of the box" is debug, as the Android Plugin for Gradle knows to use the plugin-created debug signing keystore. For everything else, you either need to:
Configure a separate signing keystore (e.g., for release)
Initialize the new build type from the debug build type, akin to using a copy constructor, so it uses the same rules that debug does for signing
In the following sample, I want to define a new mezzanine build type, giving it the same signing configuration as I use for release. So, I use mezzanine.initWith(buildTypes.release) to set up mezzanine as a copy of release, then continue to configure it with different rules:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
versionCode 2
versionName "1.1"
minSdkVersion 14
targetSdkVersion 18
}
signingConfigs {
release {
storeFile file('HelloConfig.keystore')
keyAlias 'HelloConfig'
storePassword 'laser.yams.heady.testy'
keyPassword 'fw.stabs.steady.wool'
}
}
buildTypes {
debug {
applicationIdSuffix ".d"
versionNameSuffix "-debug"
}
release {
signingConfig signingConfigs.release
}
mezzanine.initWith(buildTypes.release)
mezzanine {
applicationIdSuffix ".mezz"
debuggable true
}
}
}
In your case, you would use something like qa.initWith(buildTypes.debug) before configuring the rest of the qa build type.