0

我一直在阅读并在互联网上搜索,我发现了类似的问题,但仍然没有答案。所以我会再试一次:)

我正在使用 phonegap 2.7 开发一个应用程序,我正在使用推荐的功能来上传图片。问题是一些用户在尝试选择他们的图片时报告异常,并且应用程序崩溃了。

查看谷歌播放控制台我可以看到这个错误:

  java.lang.RuntimeException: Unable to resume activity 
  {com.xmile.events/com.xmile.events.MainActivity}: java.lang.RuntimeException: Failure 
  delivering result ResultInfo{who=null, request=18, result=-1, data=Intent { 
  dat=content://media/external/images/media/201233 }} to activity 
  {com.xmile.events/com.xmile.events.MainActivity}: java.lang.NullPointerException
  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
  at android.app.ActivityThread.access$600(ActivityThread.java:123)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:4424)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, 
  request=18, result=-1, data=Intent { dat=content://media/external/images/media/201233 }} 
  to activity {com.xmile.events/com.xmile.events.MainActivity}: 
  java.lang.NullPointerException
  at android.app.ActivityThread.deliverResults(ActivityThread.java:2980)
  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2431)
  ... 12 more
  Caused by: java.lang.NullPointerException
  at org.apache.cordova.DroidGap.onActivityResult(DroidGap.java:858)
  at android.app.Activity.dispatchActivityResult(Activity.java:4649)
  at android.app.ActivityThread.deliverResults(ActivityThread.java:2976)
  ... 13 more

选择图像的功能是这个:

function selectPicture() {
    pictureSource=navigator.camera.PictureSourceType;
    destinationType=navigator.camera.DestinationType;

    // Retrieve image file location from specified source
    navigator.camera.getPicture(
        onPhotoURISuccess, onFail, { quality: 25, 
        destinationType: destinationType.FILE_URI,
        sourceType: pictureSource.PHOTOLIBRARY });
}

所以我知道当用户选择图像并返回主进程时会出现问题......不知何故它已经死了,然后出现了一个 NPE :'( 更奇怪的是,它只发生在少数用户身上,我可以' t用我的手机复制它。

任何帮助将不胜感激!

4

1 回答 1

0

我猜您正在尝试使用 Android 版本 4.1 或 4.2。如果是这种情况,请参考以下答案: Phonegap:上传图片在三星移动 4.1.2 上崩溃,但在 Google Nexus 4.3.0 上运行良好

于 2013-12-17T12:30:53.160 回答