0

I have two app which use same ContentProvider "it.federicoboschini:resource-file-provider:1.0.0". When I Install Both Application same time it crashes, Even After I have published my app on Play store, But it has same problem.

I thought, It will resolve after changing Path and name in paths.xml. But it can't.

In Manifest :

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

Paths.xml :

<?xml version="1.0" encoding="utf-8" ?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="all" path="/"> </files-path>
</paths>

In button clicklistener

try {
    ResourceFileProvider.Builder.from(this)
        .setDirectory(FOLDER_RAW)
        .setFileName("my_sound")
        .setFileExtension("mp3")
        .setFileType(TYPE_AUDIO)
        .build()
        .shareFile();
} catch (FileNotFoundException e) {
    e.printStackTrace();
}
Synonian_raj
  • 154
  • 1
  • 13
  • "When I Install Both Application same time it crashes" -- use Logcat to examine the stack trace associated with the crash: https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this Note that you need your authority string to be unique for each app. – CommonsWare Jul 20 '19 at 13:52
  • after changing authority string it works. Is it correct authority string < **package-name.fileprovider** >. Can it effect my app ??? – Synonian_raj Jul 20 '19 at 14:15
  • You would need to ask the developers of `it.federicoboschini:resource-file-provider:1.0.0` that question. In general, using your application ID and a suffix is a good `ContentProvider` authority string, as it is unlikely that anyone else will accidentally choose the same one. – CommonsWare Jul 20 '19 at 14:23
  • It works properly. So I choose it. – Synonian_raj Jul 20 '19 at 14:26

1 Answers1

1

Looks like another application is already using this SDK with the same provider name, please change it by adding the following code to your path

android/app/src/main/res/values Strings.xml

<string name="application_id_for_provider">your.application.id.fileprovider</string>

Note: if strings.xml is not present please create and add it

Example :

<resources>
 ...
 ...
<string name="application_id_for_provider">com.yellowmessenger.ymchatbotexample.fileprovider</string>
Kiran Patil
  • 402
  • 5
  • 13