0

Can anybody tell me how I can install different builds for different flavors on one device without getting a "duplicate provider" error message neither in PlayStore nor in AndroidStudio?

I have different flavors for different countries in my app and it's annoying to always uninstall the app before installing another one.

I tried:

productFlavors {
    austria {
        manifestPlaceholders = [
            // prevent "duplicate provider authority" message
            providerAuthority: "com.example.app.at",
        ]
    }
    germany {
        manifestPlaceholders = [
            // prevent "duplicate provider authority" message
            providerAuthority: "com.example.app.de",
        ]
    }
    //...
}

and in my AndroidManifest I added:

android:authorities="${providerAuthority}"

to my

<application/> 

tag. This doesn't solve my problem.

I don't use a ContentProvider so I also tried adding a Stub ContentProvider class to the project and declared android:authorities="${providerAuthority}" inside the

<provider/> 

tag including the name of the Stub ContentProvider --> no success. I would be very happy about some other ideas or corrections.

UPDATE:

the error message I get from Android Studio when trying to install the app on my device.

this is the error message I get from Android Studio

luckyhandler
  • 10,651
  • 3
  • 47
  • 64
  • "I don't use a ContentProvider" -- then what specifically is giving you this exception? "and in my AndroidManifest I added" -- if you do not use a `ContentProvider`, where did you add this attribute? You might consider posting the entire stack trace of the installation exception, which should be showing up in LogCat. – CommonsWare Apr 22 '16 at 15:31
  • android:authorities should be added to your provider tag, please clerify your question and post the relevent sections of your manifest.xm – cyroxis Apr 22 '16 at 15:39

1 Answers1

0

I found the solution:

I lied when I said I didn't have a provider. I just didn't use it any more. So the solution for my problem was here (or simply deleting the unused provider): https://stackoverflow.com/a/24850080/3734116

I finally realized it by having a look into my generated / merged AndroidManifest in build/intermediates/manifests/ where I could find the Manifests for all my flavors. There I saw that one provider always had the same authority.

Another problem could have also been (but didn't apply to me)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
luckyhandler
  • 10,651
  • 3
  • 47
  • 64