空对象引用上的Intent.migrateExtraStreamToClipData() [英] Intent.migrateExtraStreamToClipData() on a null object reference

查看:1021
本文介绍了空对象引用上的Intent.migrateExtraStreamToClipData()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开始在我的应用的生产版本中出现此错误.

Started getting this error in the production version of my app.

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference

目前尚无明确的界线,但最近我将支持库版本更改为24.0.0.这是完整的堆栈跟踪:

There's no clear line at which this actually occurs but I recently changed my support library version to 24.0.0. Here's the full stacktrace:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference
   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1494)
   at android.app.Activity.startActivityForResult(Activity.java:3745)
   at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
   at android.app.Activity.startActivityForResult(Activity.java:3706)
   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:871)
   at com.google.android.gms.common.internal.zzi$1.zztD(Unknown Source)
   at com.google.android.gms.common.internal.zzi.onClick(Unknown Source)
   at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:162)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:135)
   at android.app.ActivityThread.main(ActivityThread.java:5254)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

编辑:我还想指出,也有100%的用户收到此错误,也已经植根.这也发生在23.4.0 ...上.我也有一个潜在的相关错误,它同时弹出,这与与Firebase有关的Base64.decode函数有关.

I also want to note that 100% of the users getting this error are also rooted. This also occurs on 23.4.0... I also have a potential related error which popped up at the same time which has to do with the Base64.decode function in relation to Firebase.

前几天,我从Android开发人员那里获得了一些帮助.他们建议我更新项目的Google Play服务版本,到目前为止,它似乎有所帮助.我要再等几天才能从用户那里得到结果,但是最初的日志很有希望.

EDIT 2: I received some help from an Android Dev the other day. They suggested that I update my project's Google Play Services version and it seems to have helped so far. I'll wait a few more days to get the results from my users but the initial logs are promising.

我以前使用的是9.0.2,但现在使用的是9.2.0.

I was previously using 9.0.2 but I'm now on 9.2.0.

更新到9.2.0并不能解决崩溃问题.我仍然从root用户那里得到同样的错误.我注意到在用户崩溃时,Android 6.0以下的版本,因此我将在实时设备上进行测试并尽快更新.

EDIT 3: Updating to 9.2.0 didn't help the crashes. I'm still getting the same error from rooted users. I've noted that at the users getting crashes are below Android 6.0 so I'll be testing on a live device and update ASAP.

推荐答案

似乎错误发生在未安装Google Play服务的设备上,传递的意图将为空.

Seems like the error occurs on devices where Google Play Services are not installed, passed intent will then be null.

您可以通过覆盖Activity中的startActivityForResult方法来确保传递的意图不为空.

You can make sure intent passed is not null by overriding startActivityForResult method in your Activity.

@Override    
public void startActivityForResult(Intent intent, int requestCode) {
    if (intent == null) {    
        intent = new Intent();        
    }       
    super.startActivityForResult(intent, requestCode);
}

这篇关于空对象引用上的Intent.migrateExtraStreamToClipData()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆