简体   繁体   English

Google Play崩溃报告中的AndroidRuntimeException

[英]AndroidRuntimeException from Google Play Crash Report

I have an app on the Google play store and it works fine for most people. 我在Google Play商店中有一个应用,对大多数人来说都可以正常运行。 However there are 90 crashes reported, via Google crash report, with the following: 但是,通过Google故障报告报告了90起崩溃,其中包括:

android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ContextImpl.startActivity(ContextImpl.java:847)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:276)
at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:242)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:330)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4429)
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:3151)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:2918)
at dalvik.system.NativeStart.main(Native Method)

I've had a look around on the web but all I can find is to add intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 我在网上浏览了一下,但是我所能找到的只是添加intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); .

But this doesn't work for me as I don't call startActivity() in my code. 但这对我不起作用,因为我没有在代码中调用startActivity() I do call startActivityForResult() but specifying the FLAG_ACTIVITY_NEW_TASK flag stops the result being returned in onActivityResult() . 我确实调用了startActivityForResult()但指定FLAG_ACTIVITY_NEW_TASK标志将停止在onActivityResult()返回结果。

Here is the only piece of code that has startActivityForResult() called from onCreate() in my Main Activity: 这是在我的主要活动中唯一具有从onCreate()调用startActivityForResult()的代码:

private void load()
{
    Intent loadBeats = new Intent(this, BeatListActivity.class);
    startActivityForResult(loadBeats, SELECT_BEAT_ACTIVITY);
}

I've never actually had this error occur for me on any of my devices or in a Virtual Device! 在我的任何设备或虚拟设备上,我从未真正发生过此错误! This all makes it difficult to solve. 这一切都很难解决。

Any ideas? 有任何想法吗?

After the helpful comments, @ReubenScratton, following my question I think I've found the problem/solution! 在提出有用的评论之后,@ ReubenScratton,在我提出问题之后,我想我已经找到了问题/解决方案!

In my code I do not use startActivity() so this confused me. 在我的代码中,我不使用startActivity() ,这使我感到困惑。 However I do use AdView (admob adverts) version 4.1.1, which does seem to call startActivity() . 但是我确实使用了AdView(admob广告)4.1.1版,它似乎确实调用了startActivity() I found this out after searching Google. 我在搜索Google后发现了这一点。 Other people had reported the same errors, as per my question, using that version of AdView (GoogleAdMobAdsSdk-4-1-1.jar). 根据我的问题,其他人使用该版本的AdView(GoogleAdMobAdsSdk-4-1-1.jar)报告了相同的错误。

I've updated my app with a newer version and, so far, there have been no more errors! 我已经用较新的版本更新了我的应用程序,到目前为止,没有更多错误了!

I will report back if this is not the case thought. 如果不是这种情况,我将报告。

Just Adding up 只是加起来

This exception also happens with interstitial ads 插页式广告也会发生这种情况

You have to pass the activity context not application context 您必须传递活动上下文而不是应用程序上下文

InterstitialAd interstitial = new InterstitialAd(this);

Incase of fragments 如果有碎片

InterstitialAd interstitial = new InterstitialAd(getActivity());

and not 并不是

InterstitialAd interstitial = new InterstitialAd(getActivity().getApplicationContext());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Google Play解密崩溃报告 - deciphering crash report from Google Play 活动响应方法中首选项管理器的 Google Play 控制台崩溃报告 - Google Play Console Crash Report on preference manager in on response method of Activity 适用于所有 Android 6.0+ 设备的 Google Play 预发布报告崩溃 - Google Play Pre-launch Report crash for all Android 6.0+ devices JVM崩溃报告 - Crash report from JVM Google Play控制台中的java.lang.IllegalStateException崩溃报告 - java.lang.IllegalStateException crash reports from Google Play Console Google Play控制台中的java.lang.RuntimeException应用程序崩溃 - java.lang.RuntimeException App Crash from Google Play Console 从Google Play安装后,ionic 1在第一次运行时崩溃 - ionic 1 crash on first run after installing from google play java.lang.IllegalArgumentException,我从游戏商店的崩溃报告中得到了建议,建议我如何解决该问题…… - java.lang.IllegalArgumentException, i got that in my crash report from play store, suggest me to how resolve that… Google Play游戏服务崩溃LibGDX游戏 - Google Play Games Service crash LibGDX Game Google Play服务错误 - 错误报告难以理解 - Google Play Services Error - Bug report Incomprehensible
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM