I am using product options in gradle / android studio to achieve the following project setup:
- Two applications that are 80% similar in the same Android studio project.
- Each application should have its own manifest package path (they should basically behave as two independent applications - they have their own google api and push keys)
I followed several tutorials in my attempt to achieve this (placeholders, several manifests), but nothing works.
Following this guide, 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 are my manifest files.
Src / main / manifest:
<?xml version="1.0" encoding="utf-8"?>
<application> </application>
CSI / 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>
CSI / 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 install the package for each individual manifest tag, as my application needs different package paths. If I do this anyway, merging will not be able to merge manifest files due to different package values. Apart from packageName, I also tried setting the "applicationId", but that would not work either. Using a placeholder like this package="${applicationId}" does not work because it does not resolve the value of the variable.
Any ideas how to solve this problem? I am using Android Studio 0.8.2 with gradle 0.12.2
android android-studio gradle
Dominik schreiber
source share