This is a follow up question. You don't need to, but you can read the first question.
Here is my problem. I created two apks from a single source. Then I published both APKs on the Google Play Store, each as independent apps. Say one app is named Cat and one is named Dog. Now I am having a problem such that if I install Cat on my device, then I cannot install Dog, and vice versa. Any idea why this might be? The error code from the PlayStore is `Error Code: -505).
EDIT: Replying to responses
I thought the suffixes would take care of that. How might I address that problem and still use a single source code for my two APKs?
productFlavors{
training{
applicationIdSuffix ".training"
versionNameSuffix "-training"
}
production{
// applicationIdSuffix ""
// versionNameSuffix ""
}
}
EDIT 2:
Adding an extra manifest for the .training flavor, resulted in the following error
/Users/myname/StudioProjects/appname/app/src/training/AndroidManifest.xml Error:
Overlay manifest:package attribute declared at AndroidManifest.xml:2:11-50 value=(com.compname.appname.training)
has a different value=(com.compname.appname.training) declared in main manifest at AndroidManifest.xml:2:11-41
Suggestion: remove the overlay declaration at AndroidManifest.xml and place it in the build.gradle:
flavorName {
applicationId = "com.compname.appname.training"
}
Where would this flavorName go exactly?
In your build.gradle,
android.productFlavors {
dog {
applicationId "com.example.dog"
}
cat {
applicationId "com.example.cat"
}
}
Now you can do,
$ gradle assembleDogDebug
or
$ gradle assembleCatDebug
etc.
This would happen because both APKs are for same package.
Related
I am trying to upload an application under development to Google Play Console, internal testing track. The application has two flavor dimensions and and two dynamic features, the last two being resources only (no code). I am relying on Android Studio to generate the directory structure and the signed bundle.
The name of the package is com.something.something. The upload fails with the message "Your APK or Android App Bundle needs to have the package name com.something.something.base."
I cannot track down the source of the problem, though it looks like it should have something to do with the flavor dimensions. On the other hand, I had no problem uploading a single apk, without the dynamic features.
I am not sure which part of the code is relevant here, which is probably part of my problem, but my main build gradle looks like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId 'com.something.something'
....
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
//testCoverageEnabled false
}
}
flavorDimensions "version"
productFlavors {
small {
dimension "version"
}
full {
dimension "version"
}
}
dynamicFeatures = [":feat1", ":feat2"]
}
dependencies {
...
}
I do not want to burden the question with irrelevant code, but can provide more if there is some intuition about where the problem might be.
I would be grateful for any suggestion on how to approach the debugging here. (Uploading is painfully slow, trial and error is not much of an option.)
Thank you all for taking a shot at the answer. Here is what I learned about this issue and how I "solved" it.
My problem starts with Google Play Console (GPC) insisting that an app name be associated with the very first package name you have uploaded. This is in addition to having one app = one package name rule. If you are still in the draft stage, you can delete the package from your "All applications" list in GPC, and upload a package with different name, but once it's published - no such luck. The way GPC is designed, all my future uploads should have the suffix ".base", if this is what my first upload had.
Next, Android Studio (AS), does something called manifest file merging. (#Fantômas, your audience may not be as omniscient as you are - the behavior of AS is relevant here, and with your permission I would return the tag.) When you choose the flavor for the bundle, the name of the flavor is suffixed to create the package name in the merged AndroidManifest file, irrespective of the name you specify in your main AndroidManifest.xml, as you can check if you choose to "analyze" (the name of the link after the bundle is generated) newly created bundle:
Thus, in my first upload I had a flavor called base, and I did not realize that AS tacked it as the suffix on the name of my package. From that point on, GPC will not take a package for my app by any other name.
One thing that is irrelevant here are dynamic features - they just happened to be part of my second upload attempt.
I have asked Google to delete my app so I can start from scratch.
Since your problem is not related to codes, try changing your package name to something else, something more "unique".
com.myname.myappname is an example. In this case you need to change everything related to your package name. Try it and report back
You do not need to delete your app from Google console. Simply open Build.gradle(Module:app) in your android studio and change the Application Id to the name google is requesting from you.
You will need to change your Application Id in your Build.Gradle(Module: app)
You may also need to change the name in your google-services.json file under this section:
"client_info": {
"mobilesdk_app_id": "...",
"android_client_info": {
"package_name": "com.yourpackagename.yourpackagename"
}
good coding!!
You can avoid "Manifest file merging" (of Android Studio...) to altering the package name of the "merged manifest" in the build variant, by excluding the applicationIdSuffix definition on the build type or flavour dimmension definition in the build.gradle (app: module), like in my following example, in what I want to avoid to adding the respective package name suffixes ".release" and ".full" in my "release" and/or "full" versions of my App:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// applicationIdSuffix ".release"
versionNameSuffix "-release"
}
debug {
proguardFiles 'proguard-project.txt'
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
}
}
// Specifies one flavor dimension.
flavorDimensions "version"
productFlavors {
free {
dimension "version"
applicationIdSuffix ".free"
versionNameSuffix "-free"
}
full {
dimension "version"
// applicationIdSuffix ".full"
versionNameSuffix "-full"
}
}
Regards,
P.D.:
And thanks a lot for all the other answers, that help me in this moment to take this my decission of doing the above posted... Thanks, especially for #celaeno, that explained how works the "Manifest merging" in Android Studio, and over all, advertised how App Id SUFFIXES may CHANGE the App.Id in Google Play Console terms...
change the applicationId in android/app/build.gradle to the same id of the previos versions.
defaultConfig {
applicationId "com.xxxxxxx.xxxx"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 12
versionName "3.2.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
targetSdkVersion 30
missingDimensionStrategy 'react-native-camera', 'general'
}
I have an Android App, which has two flavors: Basic and Advanced.
The Basic is already on the AppStore, with a package name of form com.domain.something. I would like to publish the second as com.domain.something.advanced. Is it possible? Or is the fact that the second is a sub package of the first would cause trouble?
Yes, this is possible and will not cause any problems in the Play Store.
You will want to read the Configure Build Variants guide for more information on setting up a product flavor for your "advanced" version. You can use the applicationIdSuffix in your build types or product flavors to set a suffix on your application ID for that particular variant.
Your build.gradle will end up looking something like this:
android {
defaultConfig {
applicationId "com.domain.something"
}
buildTypes {...}
productFlavors {
basic {...}
advanced {
applicationIdSuffix ".advanced"
}
}
}
You can then either programmatically check your product flavor with the generated BuildConfig class, or put your code for the advanced version in the advanced product flavor's source folder (/src/advanced/java, /src/advanced/res, etc.).
I have already asked similar question But could not find what i seek . Hence asking again .
I want to run separate flavor apk on same device simultaneously.
I have used build.gradle(app) to create different flavors of apk. But installing different flavors of same apk overrides the previous one. I want to create different apks to run on same device simultaneously. I want to create different apk with different appicon which can be installed on same device and run simultaneously. Any link or tutorial or direct help is appreciated.
My build.gradle is as below
productFlavors {
production {
applicationId
"com.abc.def"
buildConfigField 'String', 'HOST', '"http://example.com/api/"'
}
staging {
applicationId
"staging.com.abc.def"
buildConfigField 'String', 'HOST', '"http://example.com/api/"'
}
backendtesting {
applicationId
"backendtesting.com.abc.def"
buildConfigField 'String', 'HOST', '"http://example.com/api/"'
}
}
Do not put line breaks between the gradle command and it's argument. It will read each line separately since line breaks are command separators for gradle.(like how ; is for java)
For example, use:
applicationId "com.abc.def"
instead of
applicationId
"com.abc.def"
This post explains step by step how to configure your directory structure and gradle file.
The main steps are:
add the product flavours container to the app build.gradle file
productFlavors {
free {
applicationId "antoniocappiello.com.buildvariantsexample.free"
}
paid {
applicationId "antoniocappiello.com.buildvariantsexample.paid"
}
}
create inside src a directory with the exact name of the product flavour that you want to look different from the main variant, for example with the configuration at step 1 the directory name could be paid or free . And inside that directory create the subfolder res/drawable where you are going to place your new app launcher icon.
Directory structure example
You can set different applicationId for different flavors. In this way different flavors will be treated as different applications and will not overwrite each other when you install them on same device.
As an example, following snippet will create two flavors, prod and dev with different app packages. You can install them both together on the device.
productFlavors {
dev {
applicationId "com.swagata.devbuild"
}
prod {
applicationId "com.swagata.prodbuild"
}
}
I developed an android app with 3 different flavors (production,testing, training). Almost 99% of the source codes are identical. Only a single file in assert folder with server urls are different for each flavor. The flavors work perfectly. But i would like the app to install all 3 apps in the device without overwriting each other. Since the package name of the project is the same for all the flavors, it's overwriting the app when i install difference flavors.
Any ideas or suggestions ? Thanks in advance.
Anyway just by changing the package name in the build.gradle it works.
productFlavors {
production {
applicationId = "<your-package-surfix>.production"
}
testing {
applicationId = "<your-package-surfix>.testing"
}
training {
applicationId = "<your-package-surfix>.training"
}
}
In AndroidManifest.xml use full package name when define a activity/service/receiver.
I just released my first Android Application through the market. I'm currently working on some new features for the next release and would like to install this "dev build" on my phone, without uninstalling the "production" version (among other things, this will stop future updates from the Market).
I'm especially interested in this because I'd like to give the APK to friends / "beta-testers" to try, but I don't want them to uninstall the released application first.
Is there anyway to have on one device two applications: "App (via market)" and "App (DEV)"
Would this involve using a different signing key or modifying the manifest in someway?
Thanks!
You can simply rename the package, so both apps are installed.
You need to change the package name in the manifest as well as in the source folder. Use Eclipse's refactoring for it and it will be done in a minute.
They don't need to be signed with the same key.
Using Gradle this is very easy. Here's an excerpt from one of my gradle files:
android {
// ...
defaultConfig {
resValue "string", "app_name", "<app name>"
// ...
}
buildTypes {
release {
// ...
}
debug {
resValue "string", "app_name", "<app name> (debug)"
applicationIdSuffix ".debug"
// ...
}
}
}
The key part for allowing another installation is using the applicationIdSuffix that is set in the debug build. Under the hood this basically does the same thing as proposed in Force's answer; it changes the application id of your app.
Setting the resValue app_name allows us to have different app names as well, this makes it much easier to keep track of which installation is which (since both application would get the same name otherwise).
Don't forget to remove the app_name from your strings.xml and fill in your own app name instead of <app name> if you decide to set the app_name in the gradle file like I did above.