2

It works perfectly. I can view pdf BUT now i can't install others flavors in my phone because of this error:

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

Code for referecnce :

App level build.gradle file

    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
       

    }

}

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>

Note:-I follow this link but still facing the same issue can't install another falvour in same device even i remove provider tag from AndroidManifest.xml but getting same error.

Link1

Link2

Link3

Arbaz.in
  • 1,478
  • 2
  • 19
  • 41

1 Answers1

6

Your file provider authority must depend on the package name. Right now, it is not dynamic and is the same for all your flavors. You can't have multiple apps with file providers that have the same authorities value. Make this value depends on the applicationId like this:

<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>

See the documentation for reference:

In this example, the android:authorities attribute specifies the URI authority that you want to use for content URIs generated by the FileProvider. In the example, the authority is com.example.myapp.fileprovider. For your own app, specify an authority consisting of the app's android:package value with the string "fileprovider" appended to it. To learn more about the authority value, see the topic Content URIs and the documentation for the android:authorities attribute.

Alexander Hoffmann
  • 5,104
  • 3
  • 17
  • 23
  • i removed the provider code from AndroidManifest.xml still getting same error can you please tell me what wrong with this? – Arbaz.in Sep 24 '20 at 08:37
  • Thanks work for me actully issue with hard coded packge (`com.freshdesk.helpdesk.provider ` )name in one of my file so i replaces witrh applicationId.com.freshdesk.helpdesk.provider. – Arbaz.in Sep 25 '20 at 10:45