设置应用程序调味后,我在运行应用程序/时收到此错误“install_failed_conflicting_provider”

Arb*_*.in 2 android android-install-apk build.gradle android-build-flavors android-gradle-3.0

它工作完美。我可以查看 pdf,但现在由于以下错误,我无法在手机中安装其他版本:

Installation did not succeed. The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER Installation failed due to: 'null' Retry

参考代码:

应用级build.gradle文件

    defaultConfig {
    applicationId "com.abc.xyz"
    minSdkVersion 21
    targetSdkVersion 29
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"}



flavorDimensions "version"
productFlavors {
    appdev {
        dimension "version"
        applicationIdSuffix ".dev"
        versionCode buildVersionCodeDev()
        versionName version_dev

     
    }
    appqa {
        dimension "version"
        applicationIdSuffix ".qa"
        versionCode buildVersionCodeQA()
        versionName version_qa   
    }
    apppro {
        dimension "version"
        applicationIdSuffix ".pro"
        versionCode buildVersionCodePro()
        versionName version_pro
       

    }

}
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml

    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="com.freshdesk.helpdesk.provider"
        android:exported="false"
        android:grantUriPermissions="true"
        tools:replace="android:authorities">


           <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths" />
    </provider>
Run Code Online (Sandbox Code Playgroud)

Note:-我点击此链接,但仍然面临同样的问题,即使我从 AndroidManifest.xml 中删除提供程序标签,也无法在同一设备中安装另一个 favour,但出现相同的错误。

链接1

链接2

链接3

Ale*_*ann 6

您的文件提供者权限必须取决于包名称。目前,它不是动态的,并且对于您的所有口味都是相同的。您不能让多个应用程序的文件提供程序具有相同的authorities值。使这个值取决于applicationId这样的:

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

       <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths" />
</provider>
Run Code Online (Sandbox Code Playgroud)

请参阅文档以供参考:

在此示例中,android:authorities 属性指定要用于 FileProvider 生成的内容 URI 的 URI 权限。在示例中,权限为 com.example.myapp.fileprovider。对于您自己的应用程序,指定一个由应用程序的 android:package 值组成的权限,并附加字符串“fileprovider”。要了解有关权限值的更多信息,请参阅内容 URI 主题和 android:authorities 属性的文档。