INSTALL_FAILED_CONFLICTING_PROVIDER in Android

If you are using Google Maps + Google Play Services inside a library project, you can encounter this error when you try to run an app that uses your library, while a different app that uses the same library is already installed on your device.

Fix: make sure that defaultConfig.applicationId is defined in android section of the build.gradle file for each project using your library

android {
    defaultConfig.applicationId = "com.company.appname"
}

I would recommend using the package name of the specific app. With this fix, the provider names will no longer conflict, and your app will run as expected.

Symptoms

1.) Your users are seeing the dreaded "-505" install error when installing your app from the Play Store.

2.) You will see this error message when you try to install a second app that uses your library via Android Studio:

enter image description here

In your console, you will see a message like this:

Package couldn't be installed in /data/app/com.company.appname-1
com.android.server.pm.PackageManagerException: 
Can't install because provider name 
com.google.android.gms.measurement.google_measurement_service 
(in package com.company.appname) is already used by
com.company.otherInstalledAppName

The fix is to make sure that defaultConfig.applicationId is defined in android section of the build.gradle file for each project using your library

android {
    defaultConfig.applicationId = "com.company.appname"
}

More reading can be found here in the original bug report: Issue 784: Multiple apps using same authority provider name


The android :authorities value is the package name.

In this case, it happens to be the package name. It simply has to be unique.

The android:name is the name of the class of that provider

Correct.

If I change the package name, to another one different than the com.google etx, and rename all the references/ imports of that package, should the problem go away?

The package name has nothing to do with it. You may need to change that as well, though, for your app to be able to be installed alongside the regular, un-modified app.

You need to have a unique value for android:authorities, and the code in your app that uses this ContentProvider needs to use an appropriate Uri (content://whatever.you.change.the.authority.to/...).