问题
I am experimenting with the NotesList sample program in the Android SDK. I've made a slight variation in the program, but when I install my edited version I keep getting the message INSTALL_FAILED_CONFLICTING_PROVIDER in the console when I try to install it when the original notes program is already on the device. What do I need to change in the Provider to make it a unique database? It works fine if I uninstall the original notes program and then install my edited version.
回答1:
The authority, as listed in android:authorities
must be unique. Quoting the documentation for this attribute:
To avoid conflicts, authority names should use a Java-style naming convention (such as com.example.provider.cartoonprovider). Typically, it's the name of the ContentProvider subclass that implements the provider
回答2:
If you have different flavors and you want to avoid collisions in the authority name you can add an applicationIdSuffix
to build types and use the resulting applicationId
in your manifest, like this:
<...
android:authorities="${applicationId}.contentprovider"/>
回答3:
If you are using Google Maps + Google Play Services inside a library project (especially if you recently migrated from Eclipse to Android Studio), 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 [INSTALL_FAILED_CONFLICTING_PROVIDER]:
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
回答4:
This can also happen when you have an older version of your app installed and made changes to the (support) library or the manifest file. Deleting the old applications from your device (Settings --> Application --> <your application> --> Uninstall
) will solve the issue then.
回答5:
If you are using the Facebook SDK then the issue might be in the "authorities" value you provide for the Facebook provider.
REPLACE -
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.FacebookContentProvider"
android:exported="true" />
WITH ->
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.FacebookContentProvider[YOUR_APP_ID]"
android:exported="true" />
You might need to change the defaultConfig.ApplicationId
also as suggested in other answers.
回答6:
The same error may occur after renaming packages. Check the value in string.xml for android:authorities
from AndroidManifest.xml.
<provider
android:authorities="@string/content_authority"
android:name=".data.Provider"
... />
In string.xml the value should be the same as your package name, declared in manifest.
<string name="content_authority">com.whatever.android.sunshine.app</string>
回答7:
The Authority + Provider name that you have declared in the manifest probably
回答8:
Basically this happened with me, when i tried to change the package name of the app.
So, in emulator, same app was installed before. When i tried to install app after changing package name, it said, authority already used by older application in device.
Simply after uninstalling the application, it solved my problem.
Also, Authority name should always be : your.package.name.UNIQUENAME
;
example :
<provider
android:name="com.aviary.android.feather.cds.AviaryCdsProvider"
android:authorities="your.package.name.AviaryCdsProvider"
/>
回答9:
I had a similar problem when I used one library in several applications. It was necessary just update your AndroidManifest.xml with this exact provider declaration below.
<manifest ...>
<application ...>
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.here.this.library.provider" android:exported="false" android:grantUriPermissions="true" tools:replace="android:authorities">
</provider>
</application>
</manifest>
回答10:
I have tried many solution but could not find solution... but this link helped me... I want to give detail about issue...
I was running Instrumented test cases so my app was not visible in launcher... but it was installed and thus using Same Content Provider. So, I should uninstall it somehow. So Settings -> Application Manager -> All Downloaded Apps -> uninstall all apps from your current development package
Now, try to run... This will work...
回答11:
If you are using Facebook inside app check for provider tag inside AndroidManifest
file and check your project Id
is correct for android:authorities
<provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider112623702612345" android:exported="true" />
回答12:
I thought uninstalling the app by dragging its icon to "Uninstall" would solve the problem, but it did not.
Here is what solved the problem:
- Go to Settings
- Choose Apps
- Find your app (yes I was surprised to still find it here!) and press it
- In the top-right, press the 3 dots
- Select "Uninstall for all users"
Try again, it should work now.
回答13:
install using adb with command ./adb install -r abc.apk
will solve the problem (it will overwrite even when the device has higher app version)
回答14:
Encountered this issue.
Resolved it by:
1 - open AndroidManifest.xml
2 - ctrl+f find "provider"
3 - find provider and update your root directory name there.
run project. hopefully issue will be fixed!
回答15:
If you are on Xamarin and you get this error (probably because of Firebase.Crashlytics):
INSTALL_FAILED_CONFLICTING_PROVIDER
Package couldn't be installed in [...]
Can't install because provider name dollar_openBracket_applicationId_closeBracket (in package [...]]) is already used by [...]
As mentioned here, you need to update Xamarin.Build.Download:
- Update the Xamarin.Build.Download Nuget Package to 0.4.12-preview3
- On Mac, you may need to check Show pre-release packages in the Add Packages window
- Close Visual Studio
- Delete all cached locations of NuGet Packages:
- On Windows, open Visual Studio but not the solution:
- Tools -> Option -> Nuget Package Manager -> General -> Clear All Nuget Cache(s)
- On Mac, wipe the following folders:
~/.local/share/NuGet
~/.nuget/packages
packages
folder in solution
- On Windows, open Visual Studio but not the solution:
- Delete bin/obj folders in solution
- Load the Solution
- Restore Nuget Packages for the Solution (should run automatically)
- Rebuild
回答16:
In my android device I had different flavors of the same app install. This gives me error INSTALL FAILED CONFLICTING PROVIDER. so I uninstall my all flavors of the same app. and tried
adb install -r /Users/demo-debug-92acfc5.apk
It solved my problem.
来源:https://stackoverflow.com/questions/16267785/install-shows-error-in-console-install-failed-conflicting-provider