Where is the apk for my new build variant? - android

I read the "Build System" section of the android docs: http://developer.android.com/sdk/installing/studio-build.html
So a build variant is composed of a product_flavor-build_type. I have this build.gradle:
buildTypes {
debug {
applicationIdSuffix '.debug'
debuggable true
minifyEnabled !skipProguard
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.debug
zipAlignEnabled false
}
debugtest {
// unit tests
applicationIdSuffix '.test'
debuggable true
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.debug
zipAlignEnabled false
}
release {
minifyEnabled true
shrinkResources true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
productFlavors {
internal {
applicationId "${project.applicationId}.internal"
buildConfigField 'boolean', 'EXPERIMENTAL', 'true'
buildConfigField 'boolean', 'FAKE_HTTP_RESPONSE', 'false'
}
production {
applicationId project.applicationId
buildConfigField 'boolean', 'EXPERIMENTAL', 'false'
buildConfigField 'boolean', 'FAKE_HTTP_RESPONSE', 'false'
}
automation {
applicationId "${project.applicationId}.automation"
buildConfigField 'boolean', 'EXPERIMENTAL', 'true'
buildConfigField 'boolean', 'FAKE_HTTP_RESPONSE', 'true'
}
}
I'd like to create mobile-debug-automation-unaligned.apk so that I can use the "FAKE_HTTP_RESPONSE" BuildConfig variable in a dagger module.
But when I click on "Build Variants" in Android Studio I see one build variant-"internalDebug". I expected to see 9 build variants(buildType * productFlavor).
Looking in my project directories, I see the following apks:
MY_APP/mobile: mobile-release.apk, mobile-debug-unaligned.apk
MY_APP/mobile/build/outputs/apk: mobile-internal-debug-unaligned.apk
How do I generate my new "automation" apk?

Plz click on it to change:
If it doesn't work, rebuild your project.

Related

How to have multiple ApplicationIds for the same product flavor?

We have a white label application with a handful of flavors for different clients. A new client has come on that wants the ability to publish the app through their own developer account. However, prior to release, we need to test the app through our internal test track and verify that the prod environment works (such as billing).
When we got started with development, we created a new product flavor, "com.business.android.product". Now that we are getting close to release, we need a different package name, "com.example.android.thing". My question is, how can we have two package names for the same flavor (i.e. using the same code in the /product source folder)?
Here is an example of our flavor and build type setup
productFlavors {
prod1 {
applicationId "com.business.android"
buildConfigField 'boolean', 'REPORT_CRASHES', "true"
}
prod2 {
applicationId "com.business.android.product2"
buildConfigField 'boolean', 'REPORT_CRASHES', "true"
}
prod3 {
applicationId "com.business.android.product3"
buildConfigField 'boolean', 'REPORT_CRASHES', "true"
def flavor = "spg"
}
prod4 {
applicationId "com.company.android.product4"
buildConfigField 'boolean', 'REPORT_CRASHES', "true"
}
/* Need a way to have all the code in /prod4 flavor source folder but with
* a very different applicationId - ex. somebusiness.android.product4
*
*/
}
buildTypes {
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.KEY
def buildType = "debug"
def targetEnvironment = "production"
buildConfigField "boolean", "PRODUCTION_ENV", "true"
}
debugTst {
minifyEnabled false
debuggable true
signingConfig signingConfigs.KEY
def buildType = "debug"
buildConfigField "boolean", "PRODUCTION_ENV", "false"
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.KEY
def buildType = "release"
buildConfigField "boolean", "PRODUCTION_ENV", "true"
}
releaseTst {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.KEY
def buildType = "release"
buildConfigField "boolean", "PRODUCTION_ENV", "false"
}
}
This issue can be resolved by performing the follow:
sourceSets {
prod4Ext.java.srcDirs += 'src/prod4/java'
prod4Ext.res.srcDirs += 'src/prod4/res'
}
This will provide the prod4 flavor's source code and layouts to the newly created flavor prod4Ext.

App is still showing in debuggable after making debuggable false in app graddle

I have two build variants uat and prod.
In uat I am making debuggable to true while in prod I am making it to false.
But app is still showing in debuggable after making it to false.
It's happen only in case of emulator.
following is code in my app graddle file
buildTypes {
android.variantFilter { variant ->
if (variant.buildType.name.equals('release') || variant.buildType.name.equals('debug')) {
variant.setIgnore(true);
}
}
uat {
debuggable true
signingConfig signingConfigs.uat
minifyEnabled false
//zipAlignEnabled true
applicationIdSuffix ".uat"
buildConfigField "String", "URL_ENDPOINT", "\"http://your.development.endpoint.com/\""
}
prod {
debuggable false
jniDebuggable false
signingConfig signingConfigs.prod
renderscriptDebuggable false
minifyEnabled false
// zipAlignEnabled true
applicationIdSuffix ".prod"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

product flavors producing incorrect build variants

flavorDimensions 'publish', 'develop'
productFlavors {
live {
dimension 'publish'
}
dev {
dimension 'develop'
applicationIdSuffix ".dev"
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
zipAlignEnabled true
debuggable true
productFlavors.live.signingConfig buildSignConfig.debug
productFlavors.dev.signingConfig buildSignConfig.debug
}
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
productFlavors.live.signingConfig buildSignConfig.release
productFlavors.dev.signingConfig buildSignConfig.release
}
}
I have 2 library modules and in application gradle file, I have above flavorDomensions, productFlavors and buildTypes. This produces build variant incorrectly like liveDevDedug and liveDevRelease. What could be the possible errors? Using AS 3.0

Assign different build types to different Flavors in android

In my Gradle file, I've assigned buildTypes and productFlavors in the following way.
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
signingConfigs {
release{
//storeFile file("")
//storePassword ""
//keyAlias ""
//keyPassword ""
}
}
flavorDimensions "default"
productFlavors {
dev{
dimension "default"
applicationId "com.xxx.android.dev"
}
qa{
dimension "default"
applicationId "com.xxx.android.qa"
}
staging{
dimension "default"
applicationId "com.xxx.android.staging"
}
prod{
dimension "default"
applicationId "com.xxx.android.prod"
}
}
Now the problem is each flavors has the both build types which is release and debug , But I want to assign debug for build only so we cannot produce a release build when selecting debug variant. Any idea how to do it?
I managed to get it done by adding build targets. i didn't want to change any source codes for this . so no need to go with flavors
buildTypes {
qa {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', ‘BASE_URL', ‘"url“'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', ‘BASE_URL', ‘"url“'
}
debug {
buildConfigField 'String', ‘BASE_URL', ‘"url“'
}
}

Android buildTypes multiple debug modes

I have three build types, and I am trying to get the staging build type to run but I am getting the following error:
Error: The apk for your currently selected variant (app-staging-unsigned.apk) is not signed. Please specify a signing configuration for the variant (staging).
Is there a way for me to run staging without signing, as like a second debug?
android {
buildTypes {
debug {
buildConfigField "String", "SERVER", '"dev.gamesmart.com"'
}
staging {
buildConfigField "String", "SERVER", '"staging.gamesmart.com"'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "SERVER", '"gamesmart.com"'
}
}
}
Try:
android {
buildTypes {
debug {
buildConfigField "String", "SERVER", '"dev.gamesmart.com"'
}
staging.initWith(buildTypes.debug)
staging {
buildConfigField "String", "SERVER", '"staging.gamesmart.com"'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "SERVER", '"gamesmart.com"'
}
}
}
This says "have staging start as a clone of debug, then we'll modify from there", so staging should apply the debug signing config.

Categories

Resources