I'm trying to create a single project with 2 flavors: free and pro (versions).
My app is already in PlayStore with different packages (E.g.: com.example.appfree and com.example.app)
This is my build.gradle:
defaultConfig { applicationId "com.example.appfree" } productFlavors{ lite { applicationIdSuffix 'lite' } pro { } }
And this is my manifest file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.app"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".SplashScreenActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity"/> </application> </manifest>
I tried to upload a build apk for free and pro flavors. Pro flavor is ok, but free flavor isnt accepted by Google, because the package is incorrect. How can I solve this?
====== Solved: ====== applicationIdSuffix only works with buildTypes.
package Id (bundle Id is name used on iOS) does not really matter except for the moments you see it like in the case of play store links. Yet, the only thing that technically matters is to make it unique among all published apps (which it is the case, otherwise you would not be able to publish).
The package name is the identitiy of the application. To rename the package name, In eclipse right click on the project in project explorer. Then Android Tools > rename Aplication Package name. Then enter the new package name.
All Android apps have a package name. The package name uniquely identifies the app on the device; it is also unique in the Google Play store.
With the new Android Gradle build system, you can easily build multiple different versions of your app; for example, you can build both a "free" version and a "pro" version of your app (using flavors), and these should have different packages in the Google Play store such that they can be installed and purchased separately, both installed at the same time, and so on. Similarly, you may also build both "debug" and "alpha" and "beta" versions of your app (using build types) and these can also similarly contribute to unique package names.
app/build.gradle:
apply plugin: 'com.android.application' android { compileSdkVersion 19 buildToolsVersion "19.1" defaultConfig { applicationId "com.example.my.app" minSdkVersion 15 targetSdkVersion 19 versionCode 1 versionName "1.0" } ...
app/build.gradle:
productFlavors { pro { applicationId = "com.example.my.pkg.pro" } free { applicationId = "com.example.my.pkg.free" } } buildTypes { debug { applicationIdSuffix ".debug" } } ....
from Android Studio Project Site - ApplicationId versus PackageName
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