I have two product flavors in my build.gradle which are as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.2"
aaptOptions.setProperty("cruncherEnabled", false)
defaultConfig {
minSdkVersion 15
targetSdkVersion 16
applicationId "com.example.app"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
def final myApplicationId = 'com.example.app'
def final appName = 'app'
productFlavors {
dev {
resValue "string", "app_name", appName
resValue "string", "APIURL", "http://prod.example.com/"
}
production {
resValue "string", "app_name", appName
resValue "string", "APIURL", "http://test.example.com/"
}
}
buildTypes{
dtest {
applicationIdSuffix ".dev"
}
dprod{
}
}
}
dependencies {
compile()
few libraries
}
my dev/AndroidManifest.xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app.dev"
android:installLocation="auto"
android:versionCode="3"
android:versionName="3.1">
</manifest>
and my production/AndroidManifest.xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:installLocation="auto"
android:versionCode="3"
android:versionName="3.1">
</manifest>
my main/AndroidManifest.xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:installLocation="auto"
android:versionCode="3"
android:versionName="3.1">
<application>
<activity list.. </activity>
</application>
</manifest>
I want to install dev and production flavor in the same device, but I am not able to change the package name even when I have set different applicationId. I suspect package name that I mentioned in main manifest is overriding the applicationId from build.gradle in some way or another. I'd appreciate if someone points me in right direction. Thanks.
Rather than setting that in
productFlavors
, add that inbuildTypes
Use
Update