INSTALL_FAILED_CONFLICTING_PROVIDER in Android

2020-02-27 09:33发布

I am using an open-srouce code from Google for an app called MyTracks.

I am getting this error when the original app is installed on the phone.

INSTALL_FAILED_CONFLICTING_PROVIDER

I know that this is because of the android:authorities in the Manifest.

here is the part of the Manifest:

<provider
android:name="com.google.android.apps.mytracks.content.MyTracksProvider"
android:authorities="com.google.android.maps.mytracks"
android:exported="true"
android:readPermission="com.google.android.apps.mytracks.READ_TRACK_DATA"
android:writePermission="com.google.android.apps.mytracks.WRITE_TRACK_DATA" />
<!-- Search suggestion provider -->
<provider
android:name="com.google.android.apps.mytracks.content.SearchEngineProvider"
android:authorities="com.google.android.maps.mytracks.search"
android:exported="false" />

So, my question is: I want to know whether this approach may solve the problem or not, because I am afraid of changing all the packages names and then have the whole app broken.

  1. The android :authorities value is the package name. The android:name is the name of the class of that provider. Am I 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?

10条回答
Explosion°爆炸
2楼-- · 2020-02-27 10:16

The gradle also needs to contain this

defaultConfig {
  applicationId "com.example.app"
}

I had left it out completely

查看更多
做自己的国王
3楼-- · 2020-02-27 10:18

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/...).

查看更多
倾城 Initia
4楼-- · 2020-02-27 10:18

just uninstall helloFacebooksample app from you device

查看更多
相关推荐>>
5楼-- · 2020-02-27 10:24

I got this same error when I changed the package name in my app's manifest. This creates a conflict when you try to install the app again (with the new package name). The solution is to remove the old version of the app (that uses the old package name), then you'll be able to install the new version.

查看更多
登录 后发表回答