本文介绍了在Instrumentation.execStartActivity的Andr​​oid NullPointerException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到一些用户的波纹管异常:

 显示java.lang.NullPointerException
    在android.app.Instrumentation.execStartActivity(Instrumentation.java:1414)
    在android.app.Activity.startActivityForResult(Activity.java:2880)
    在android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
    在android.app.Activity.startActivity(Activity.java:2986)
    在com.google.android.gms.internal.bb $ 5.onClick(来源不明)
    在android.view.View.performClick(View.java:2535)
    在android.view.View $ PerformClick.run(View.java:9130)
    在android.os.Handler.handleCallback(Handler.java:618)
    在android.os.Handler.dispatchMessage(Handler.java:123)
    在android.os.Looper.loop(的SourceFile:351)
    在android.app.ActivityThread.main(ActivityThread.java:3826)
    在java.lang.reflect.Method.invokeNative(本机方法)
    在java.lang.reflect.Method.invoke(Method.java:538)
    在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:969)
    在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
    在dalvik.system.NativeStart.main(本机方法)
 

我发现了类似的问题这里但它不是照顾自四月。我所知道的是,它是复制一个三星Galaxy Y(GT-S5360)和我使用谷歌地图Android的API V2。

你有什么想法,我怎样才能使一个解决方法吗?

解决方案

我也有同样的错误,我也用谷歌地图API。这似乎发生在所有的Andr​​oid版本和手机。仅举几例:

AN10DG3,GT-I8190,F815,GT-I9300,GOOPHONE,HTC一,KFTT,MID8127,KFAPWI,AN10DG3

 显示java.lang.NullPointerException
在android.app.Instrumentation.execStartActivity(Instrumentation.java:1409)
在android.app.Activity.startActivityForResult(Activity.java:3351)
在android.app.Activity.startActivityForResult(Activity.java:3312)
在android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
在android.app.Activity.startActivity(Activity.java:3522)
在android.app.Activity.startActivity(Activity.java:3490)
在com.google.android.gms.dynamic.a $ 5.onClick(来源不明)
在android.view.View.performClick(View.java:4084)
在android.view.View $ PerformClick.run(View.java:16966)
在android.os.Handler.handleCallback(Handler.java:615)
在android.os.Handler.dispatchMessage(Handler.java:92)
在android.os.Looper.loop(Looper.java:137)
在android.app.ActivityThread.main(ActivityThread.java:4745)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:511)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
在dalvik.system.NativeStart.main(本机方法)
 

因为我读的地方,解决办法是:

  @覆盖
公共无效startActivityForResult(意向意图,诠释请求code){
    尝试 {
        super.startActivityForResult(意向,要求code);
    }赶上(例外五){
        //修复了谷歌地图的bug:http://stackoverflow.com/a/20905954/2075875
    }
}
 

I keep getting the bellow exception from some users:

java.lang.NullPointerException
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1414)
    at android.app.Activity.startActivityForResult(Activity.java:2880)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
    at android.app.Activity.startActivity(Activity.java:2986)
    at com.google.android.gms.internal.bb$5.onClick(Unknown Source)
    at android.view.View.performClick(View.java:2535)
    at android.view.View$PerformClick.run(View.java:9130)
    at android.os.Handler.handleCallback(Handler.java:618)
    at android.os.Handler.dispatchMessage(Handler.java:123)
    at android.os.Looper.loop(SourceFile:351)
    at android.app.ActivityThread.main(ActivityThread.java:3826)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:538)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
    at dalvik.system.NativeStart.main(Native Method)

I've found a similar problem here but it's not taken care of since April. All I know is that it was reproduced on a Samsung Galaxy Y (GT-S5360) and I'm using Google Maps Android API v2.

Do you have any idea how can I make a workaround for this?

解决方案

I have the same error, I also use Google Maps API. It seems to happen on all Android versions and phones. Just to mention few:

AN10DG3, GT-I8190, F815, GT-I9300, GOOPHONE, HTC One, KFTT, MID8127, KFAPWI, AN10DG3

java.lang.NullPointerException
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1409)
at android.app.Activity.startActivityForResult(Activity.java:3351)
at android.app.Activity.startActivityForResult(Activity.java:3312)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
at android.app.Activity.startActivity(Activity.java:3522)
at android.app.Activity.startActivity(Activity.java:3490)
at com.google.android.gms.dynamic.a$5.onClick(Unknown Source)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

as I read somewhere, solution is:

    @Override
public void startActivityForResult(Intent intent, int requestCode) {
    try {
        super.startActivityForResult(intent, requestCode);
    } catch (Exception e) {
        // fixes Google Maps bug: http://stackoverflow.com/a/20905954/2075875
    }
}

这篇关于在Instrumentation.execStartActivity的Andr​​oid NullPointerException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:28