Steffaan / cordova-plugin-local-notifications

Cordova Local Notifications Plugin
Apache License 2.0
31 stars 38 forks source link

Android app crashes due to NullPointerException on android.support.v4.content.FileProvider.parsePathStrategy #17

Closed SimonBrazell closed 5 years ago

SimonBrazell commented 5 years ago

Android app crashes due to NullPointerException on android.support.v4.content.FileProvider.parsePathStrategy

Your Environment

Expected Behavior

Plugin should not conflict with other installed plugins.

Actual Behavior

This intermittent crash appears to be caused by this plugin conflicting with the Cordova Camera plugin provider, see this excerpt from the AndroidManifest.xml file of my project:

<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
        </provider>
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="de.appplant.cordova.plugin.notification.util.AssetProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/localnotification_provider_paths" />
        </provider>

As you can see both have android:authorities="${applicationId}.provider" which I believe is causing the problem.

Please see this issue on the original repo and this SO post for more details.

Steps to Reproduce

Create a project that uses both this plugin and the Camera plugin.

Context

Use both the camera and this plugin in the same project built for Android.

Debug logs

Stacktrace reported by the Google Play Console:

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:604)
  at android.support.v4.content.FileProvider.getPathStrategy (FileProvider.java:578)
  at android.support.v4.content.FileProvider.attachInfo (FileProvider.java:391)
  at android.app.ActivityThread.installProvider (ActivityThread.java:6239)
Steffaan commented 5 years ago

Thanks, merged your pull request!