I'm using Product Variants in gradle/android studio to achieve the following project setup:
I've followed multiple tutorials in my attempt to achieve this (placeholders, multiple manifests) but nothing works.
Following this tutorial I did the following: http://www.kevinrschultz.com/blog/2014/03/23/using-android-content-providers-with-multiple-package-names/
My build.gradle:
android {
compileSdkVersion 19
buildToolsVersion '20'
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
app1 {
packageName "com.test.app1"
//applicationId "com.test.app1"
}
app2 {
packageName "com.test.app2"
//applicationId "com.test.app2"
}
}}
And here my manifest files.
src/main/manifest:
<?xml version="1.0" encoding="utf-8"?>
<application>
</application>
src/app1/manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.test.app1”
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.app1.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
src/app2/manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.test.app2”
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.app2.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
This gives me the following error message:
Manifest merger failed : Main AndroidManifest.xml at AndroidManifest.xml manifest:package attribute is not declared
Unfortunately I can't set a package to each individual manifest tag as my app requires different package paths. If I do it anyway, the merger is not able to merge the manifest files because of different package values. Besides packageName I also tried setting "applicationId" but this doesn't work, either. Using a placeholder like this package="${applicationId}"
doesn't work because it doesn't resolve the variable value.
Any ideas how to solve this problem? I'm using Android Studio 0.8.2 with gradle 0.12.2
Products with variants are products that have similarities, they are based on the same model, but differ in some aspects from one another. They offer customers various purchase options for a product such as different colors, sizes, dimensions, flavors, etc.
A specific item that is bundled in with related variants to form one distinguishable product is known as a product variant. Product variants have unique identifiers, such as price, and every variant is based on the same product definition.
Having product variants presented in an intuitive, compact, and single-page way enables customers to easily compare the other product options. Therefore, offering product variants creates an opportunity to drive more sales.
To use this feature, simply go to the “Variants” tab of your product page and select the “Add Variant Option” button. From there, you can choose what kind of option you want to add (such as size or color), and then enter the different values for that option (such as small, medium, large).
You can safely add
<manifest xmlns:android="..."
package="com.test.app">
</manifest>
in your main manifest.
But you have to use applicationId
and not packageName
in your build.gradle.
The applicationId
of the build.gradle will overwrite this value during your different builds.
A better way of doing this would be to use applicationIdSuffix
instead of applicationId
for your different product flavors.
The field have to be present in your main manifest.
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