我一直在阅读很多并在互联网上搜索,我发现了类似的问题,但仍然没有答案。所以我会再试一次:))
我正在开发一个带有phonegap 2.7的应用程序,我正在使用推荐的功能来上传图片。问题是某些用户在尝试选择图片时报告异常,而且应用程序崩溃了。
查看Google Play控制台,我可以看到此错误:
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出现了:'(更奇怪的是,它只发生在一些用户和我无法用手机重现它。
任何帮助都将受到高度赞赏!
答案 0 :(得分:0)
我猜您正在尝试使用Android 4.1或4.2版。如果是这样的话,请参考这个答案: Phonegap : Upload picture crashes on Samsung mobile 4.1.2 but works fine on Google Nexus 4.3.0