I'm having a heck of a time getting a new build process for our Android Application to work. I'd like to have two different APKs that I can install side by side on the same device. However, I'm getting an error message that seems to be very common for people dealing with different APK configurations. The erorr message is as follows when I go to install the .release version the app after I've installed the .debug version -- "App not installed. The package conflicts with an existing package by the same name." Here is my build.gradle file for the application.
apply plugin: 'com.android.application'
Properties props;
if (project.hasProperty("AndroidProject.signing")
&& new File(project.property("AndroidProject.signing")).exists()) {
props = new Properties()
props.load(new
FileInputStream(file(project.property("AndroidProject.signing"))))
}
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
versionCode 12
versionName "2.4"
ndk {
abiFilters "armeabi-v7a", "x86", "mips"
}
}
flavorDimensions "default"
lintOptions {
abortOnError false
}
signingConfigs {
release {
if (props != null) {
storeFile file(props['STORE_FILE'])
storePassword props['STORE_PASSWORD']
keyAlias props['KEY_ALIAS']
keyPassword props['KEY_PASSWORD']
} else {
//Don't sign it with anything. APK will append "unsigned" to itself.
}
}
debug {
keyAlias 'debug'
storeFile file('a file path not revealed')
keyPassword 'debugandroid'
storePassword 'debugandroid'
}
}
buildTypes {
debug {
debuggable true
applicationIdSuffix ".debug"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
if (props != null) {
signingConfig signingConfigs.release
}
debuggable false
applicationIdSuffix ".release"
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
// implementation 'com.esri.arcgisruntime:arcgis-android:100.2.0'
implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'
implementation project(':lucityREST')
implementation project(':lucityCore')
implementation project(':lucityAndroidCore')
implementation 'com.android.support:support-v4:25.4.0'
}
A little bit of background on the project. This is a conversion from ANT to Gradle. The main application module that this build script is for sits on top of 3 smaller modules. Things I've tried to resolve the issue.
Completely different, explicit applicationIds for the release and debug versions.
Using productFlavors and trying different versionCodes, versionNames, applicationIds, etc.
Switching out keystores just to see if it's some sort of signing issue. Currently I have a debug signing that is not very important and uses a generated keystore through android studio. In addition I have the release keystore information in a .properties file maintained on a different machine and referenced outside the project (not checked into version control) for security purposes. These both build and the application works fine.
I've analyzed the both the .debug and .release APKs after they've been generated in Android Studio. The package names reflect the change using "applicationIdSuffix" in the build script.
I've also tried other small tweaks and ways of organizing the structure that I don't think are truly relevant to the discussion or would be to blame for the problem.
Does anyone have any idea what is causing this? Is it a possible side-effect of the migration from ANT? Any thoughts or ideas would be greatly appreciated. Thanks!
Edit 1:
Here is the result of running "appt dumb badging" on my debug apk. As you can see, the package name reflects that the .debug suffix has been added.
package: name='com.lucity.tablet2.debug' versionCode='12' versionName='2.4' platformBuildVersionName=''
sdkVersion:'15'
targetSdkVersion:'25'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
application-label:'Lucity 2.0 - QA'
application-icon-160:'res/drawable-hdpi-v4/lucity_launcher.png'
application-icon-240:'res/drawable-hdpi-v4/lucity_launcher.png'
application-icon-320:'res/drawable-xhdpi-v4/lucity_launcher.png'
application-icon-480:'res/drawable-xxhdpi-v4/lucity_launcher.png'
application: label='Lucity 2.0 - QA' icon='res/drawable-hdpi-v4/lucity_launcher.png'
application-debuggable
launchable-activity: name='com.lucity.tablet2.ui.login2.ClientPickerActivity' label='Lucity 2.0 - QA' icon=''
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
uses-implied-permission: name='android.permission.READ_EXTERNAL_STORAGE' reason='requested WRITE_EXTERNAL_STORAGE'
feature-group: label=''
uses-gl-es: '0x20000'
uses-feature-not-required: name='android.hardware.location'
uses-feature-not-required: name='android.hardware.location.gps'
uses-feature-not-required: name='android.hardware.location.network'
uses-feature-not-required: name='android.hardware.wifi'
uses-feature: name='android.hardware.faketouch'
uses-implied-feature: name='android.hardware.faketouch' reason='default feature for all apps'
uses-feature: name='android.hardware.screen.landscape'
uses-implied-feature: name='android.hardware.screen.landscape' reason='one or more activities have specified a landscape orientation'
main
other-activities
other-services
supports-screens: 'small' 'normal' 'large' 'xlarge'
supports-any-density: 'true'
locales: '--_--'
densities: '160' '240' '320' '480'
native-code: 'armeabi-v7a' 'x86'
An Android app is identified by a package name, eg com.foo.bar. You can only ever have one app with a given package name installed on a device at once. If you want your release and debug builds to both be installed on the same device, you will need to give them different package names, eg com.foo.bar and com.foo.bar.debug.
In gradle this is called the applicationId.
It looks like the applicationIdSuffix setting in your gradle file is not having the correct effect.
If you use the aapt tool with the command line aapt dump badging on your APK you can see which package name is actually being written to your APK, and maybe see where the problem is, as it looks like the suffix isn't being used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With