techaffinity / freshchat-phonegap

Freshchat sdk for phonegap
7 stars 36 forks source link

NullPointerException on FileProvider #19

Closed jasonandress closed 5 years ago

jasonandress commented 6 years ago

I'm getting the below exception for mostly Android 8.1 and Android 9 (v28). I cannot duplicate this with my test devices, but I get plenty of them reported on the Android ANR and Crash console. From what I can tell this happens when the app is in the background. it simply crashes and gives the user the "(App Name) has crashed/stopped working". I have confirmed this plugin to be the only that uses the FileProvider.

Any help is greatly appreciated.

java.lang.RuntimeException: at android.app.ActivityThread.installProvider (ActivityThread.java:6242) at android.app.ActivityThread.installContentProviders (ActivityThread.java:5805) at android.app.ActivityThread.handleInstallProvider (ActivityThread.java:3058) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1806) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loop (Looper.java:164) at android.app.ActivityThread.main (ActivityThread.java:6494) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807) Caused by: java.lang.NullPointerException: at android.support.v4.content.FileProvider.parsePathStrategy (FileProvider.java:591) at android.support.v4.content.FileProvider.getPathStrategy (FileProvider.java:565) at android.support.v4.content.FileProvider.attachInfo (FileProvider.java:378) at android.app.ActivityThread.installProvider (ActivityThread.java:6239)

jasonandress commented 5 years ago

This issue is due to the AndroidManifest.xml entry below. Specifically android:authorities=${applicationId}.provider. This conflicts with any other plugin that also uses a generic "provider" value. Since the use of this is inside Freshchat's SDK you can't fix the issue here. Change it in your other plugin.

        <config-file target="AndroidManifest.xml" parent="application" mode="merge">
            <provider
            android:name="com.techaffinity.phonegap.plugins.FileProvider" android:authorities="${applicationId}.provider" android:exported="false"
            android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/freshchat_phonegap_provider_paths" />
        </provider>
    </config-file>
techaffinity commented 5 years ago

jasonandress Thanks for the clarification, We are closing this issue.