我正在使用Android SDK中的NotesList示例程序进行试验。我在程序中做了轻微的更改,但是当我安装我的编辑版本时,当我尝试在设备上已经安装原始notes程序时,我在控制台中一直得到消息INSTALL_FAILED_CONFLICTING_PROVIDER。我需要在提供者中更改什么以使其成为唯一的数据库?如果我卸载原来的notes程序,然后安装我编辑过的版本,它就可以正常工作。


当前回答

如果你有不同的风格,你想避免在权威名称上的冲突,你可以添加一个applicationIdSuffix来构建类型,并在你的清单中使用结果的applicationId,如下所示:

<...
 android:authorities="${applicationId}.contentprovider"/>

其他回答

重命名包后可能会出现相同的错误。从AndroidManifest.xml中检查android:权威的string.xml中的值。

<provider
        android:authorities="@string/content_authority"
        android:name=".data.Provider"
        ... />

在string.xml中,该值应该与manifest中声明的包名相同。

<string name="content_authority">com.whatever.android.sunshine.app</string>

如果您正在使用提供者检查,并按照以下方法进行检查

        <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="androidx.multidex.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_path" />
    </provider>

或者使用它

    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.contentprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_path" />
    </provider>

此外,如果应用程序已经退出在您的移动卸载,然后检查

当你安装了旧版本的应用程序并对(支持)库或清单文件进行了更改时,也会发生这种情况。删除旧的应用程序从您的设备(设置->应用程序-> <您的应用程序> ->卸载)将解决这个问题。

我有这个错误,当实现一个库与以下AndroidmManifest.xml

<provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="library.path.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths"/>
    </provider>

当我在Project AndroidManifest.xml (app/src/main)中放入以下代码时,我解决了这个问题:

<provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true"
        tools:replace="android:authorities">
    </provider>

您可以卸载名称为“com”的软件包。在你运行应用程序之后,你在其中运行应用程序的设备。这对我很有效