1

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?

Community
  • 1
  • 1
Nouvel Travay
  • 6,292
  • 13
  • 40
  • 65
  • package name are important they must be unique, android OS recognized the package name, not the app name :) – Roljhon Jan 10 '17 at 21:14
  • see my added edits. – Nouvel Travay Jan 10 '17 at 21:20
  • As a side note: I thought Google Play didn't allow the same package name to be used twice? On Google Play the package names are different. Once has a suffix and one does not? Could it be a certificate_hash problem? I mean the certificate_hash in the google-services.json files? – Nouvel Travay Jan 10 '17 at 21:21
  • I guess that's not the actual package name google play handles :) not pretty sure, but I think that's the case. – Roljhon Jan 10 '17 at 21:32
  • Also I get `Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]` when I try to install both from terminal with `adb install` – Nouvel Travay Jan 10 '17 at 21:37
  • Just remember that a package name is a unique identifier of your app which resides on the android manifest which your device recognizes. Apps must have unique package names, I'm just not sure why google play allows you to upload both apps. – Roljhon Jan 10 '17 at 21:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/132852/discussion-between-roljhon-and-nouvel-travay). – Roljhon Jan 10 '17 at 21:57
  • Well, Gradle is supposed to supersede the manifest. And so that works there, i.e. using the suffixes. So this may be a Google Play bug. Still I would love a workaround. – Nouvel Travay Jan 10 '17 at 21:57
  • I found this seemingly good article. But it's not working either: https://blog.grandcentrix.net/how-to-install-different-app-variants-on-one-android-device/ – Nouvel Travay Jan 11 '17 at 02:33

2 Answers2

1

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.

Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
  • Here is what I get when I call through the terminal: I type `gradle assembleTrainingDebug` and get from the terminal `bash: gradle: command not found` – Nouvel Travay Jan 11 '17 at 01:15
  • Substitute `gradle` with however your normally invoke gradle. Maybe you use the wrapper? Maybe you are on Windows? – Jeffrey Blattman Jan 12 '17 at 16:56
0

This would happen because both APKs are for same package.