Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13200

Android app crash when accessing camera in release build only

VotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Cannot Reproduce
    • None
    • None
    • cordova-plugin-camera
    • None

    Description

      Recent changes to the camera plugin were added to use FileProvider instead of "file://" URIs to fix this bug originally. The changes seem to work when building and testing a debug apk, but (at least in my case) fail upon using a release build. Is anyone else seeing this?

      My project has been upgraded to the latest of cordova and the camera plugin:
      > cordova-plugin-camera 2.4.1 "Camera"
      > cordova -v
      > "7.0.1"

      If I run the project through Android Studio, everything works great. If I use "gradlew assembleRelease" or build a signed apk via Android Studio's interface, the app crashes.

      The crash occurs after choosing "Camera" from the dialog for where to source a photo, and then after clicking "Allow" on the Android permissions prompt (assuming you haven't given permissions yet.)

      Below is the full stack trace of one of the recent crashes. I believe this is the same exception and stack trace as the original crash that the recent changes in the camera plugin were fixing.

      Please let me know if you need additional details.

      Stack Trace:

      java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=0, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {edu.okstate.traditions/com.essenzasoftware.essenzaapp.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
                                                             at android.app.ActivityThread.deliverResults(ActivityThread.java:4090)
                                                             at android.app.ActivityThread.handleSendResult(ActivityThread.java:4133)
                                                             at android.app.ActivityThread.-wrap20(ActivityThread.java)
                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1534)
                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                             at android.os.Looper.loop(Looper.java:154)
                                                             at android.app.ActivityThread.main(ActivityThread.java:6121)
                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
                                                          Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
                                                             at android.support.v4.content.FileProvider.b(SourceFile:583)
                                                             at android.support.v4.content.FileProvider.a(SourceFile:557)
                                                             at android.support.v4.content.FileProvider.a(SourceFile:399)
                                                             at org.apache.cordova.camera.CameraLauncher.takePicture(SourceFile:295)
                                                             at org.apache.cordova.camera.CameraLauncher.onRequestPermissionResult(SourceFile:1314)
                                                             at org.apache.cordova.CordovaInterfaceImpl.onRequestPermissionResult(SourceFile:214)
                                                             at com.essenzasoftware.essenzaapp.MainActivity.onRequestPermissionsResult(SourceFile:1099)
                                                             at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7087)
                                                             at android.app.Activity.dispatchActivityResult(Activity.java:6939)
                                                             at android.app.ActivityThread.deliverResults(ActivityThread.java:4086)
                                                             at android.app.ActivityThread.handleSendResult(ActivityThread.java:4133) 
                                                             at android.app.ActivityThread.-wrap20(ActivityThread.java) 
                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1534) 
                                                             at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                             at android.os.Looper.loop(Looper.java:154) 
                                                             at android.app.ActivityThread.main(ActivityThread.java:6121) 
                                                             at java.lang.reflect.Method.invoke(Native Method) 
                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 
      

      Here is the provider section in my Manifest xml file:

              <provider
                  android:name="android.support.v4.content.FileProvider"
                  android:authorities="${applicationId}.provider"
                  android:exported="false"
                  android:grantUriPermissions="true">
                  <meta-data
                      android:name="android.support.FILE_PROVIDER_PATHS"
                      android:resource="@xml/provider_paths" />
              </provider>
      

      And here is the provider_paths.xml relevant source:

      <paths xmlns:android="http://schemas.android.com/apk/res/android">
          <external-path name="external_files" path="."/>
      </paths>
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            kyleessenza Kyle
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment