Re: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag

2,432 views
Skip to first unread message

William Ferguson

unread,
Nov 19, 2012, 5:56:48 PM11/19/12
to google-adm...@googlegroups.com
How are you constructing your AdView?

On Monday, November 19, 2012 9:34:22 PM UTC+10, Emanuele Ricci wrote:
I've just added in attachment the report file with statistics. In the latest day we got like 16k (daily) crash caused by this bug and we're SURE that this is AdMob SDK's fault because we enabled it on friday, the day that app started to crash.

Full bug info:

0
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
1
at android.app.ContextImpl.startActivity(ContextImpl.java:947)
2
at android.content.ContextWrapper.startActivity(ContextWrapper.java:283)
3
at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:278)
4
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:381)
5
at android.os.Handler.dispatchMessage(Handler.java:99)
6
at android.os.Looper.loop(Looper.java:137)
7
at android.app.ActivityThread.main(ActivityThread.java:4517)
8
at java.lang.reflect.Method.invokeNative(Native Method)
9
at java.lang.reflect.Method.invoke(Method.java:511)
10
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
11
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
12
at dalvik.system.NativeStart.main(Native Method)


Statistics: 

- it crash on all android os versions (if you want I can upload the pie graph from crittercism)
- we're actually using GoogleAdMobAdsSdk-6.2.1.jar and libGoogleAnalyticsV2.jar

If you need more information please answer to this post.

Cheers, Emanuele.






Easy Apps

unread,
Nov 20, 2012, 8:16:50 PM11/20/12
to google-adm...@googlegroups.com
I got the same crash recently, 30 reports everyday.
it crash on any Android version.
I use Admob4.1.1.

2012/11/19 Emanuele Ricci <e.r...@designfuture.it>






--
 
 
 



--
BRs
EasyApps

Eric Leichtenschlag

unread,
Nov 21, 2012, 6:13:09 PM11/21/12
to google-adm...@googlegroups.com
If you're using an old version of the SDK, you should upgrade to the latest version. There was a change that is supposed to greatly reduce these exceptions. 16K is quite a lot though, so we'll need to take another look at this.

Emanuele, is this reproducible at all? Which devices/versions of Android is this crash most popular on?

Thanks,
Eric


--
 
 
 



--

Eric Leichtenschlag | Developer Programs Engineer | eleich...@google.com | 650-776-5591


Easy Apps

unread,
Nov 23, 2012, 11:07:20 PM11/23/12
to google-adm...@googlegroups.com
I think I found the root cause. 
it is not related to the Admob sdk version.
when screen orientation changed, I will remove the Adview and create it again to fit the new screen width.
below is the code for remove Adview.

av.stopLoading();
RelativeLayout layout = (RelativeLayout)findViewById(R.id.relativelayout);
layout.removeView(av);
av.destroy();
av = null;

it is very easy to reproduce the crash on emulator. you can use ctrl+F11 to change screen orientation.
if I don't invoke av.destroy(), the crash will never happen.
finally I add Thread.sleep(10000) before av.destroy(). it seems also work.

2012/11/22 Eric Leichtenschlag <eleich...@google.com>

--
 
 
 



--
BRs
EasyApps

William Ferguson

unread,
Nov 25, 2012, 5:36:00 AM11/25/12
to google-adm...@googlegroups.com
That was a really common bug in 4.1.1.
I think it even persisted up until 4.3.1

I have seen very little of it since upgrading to 6.2

William

Easy Apps

unread,
Nov 25, 2012, 7:35:38 AM11/25/12
to google-adm...@googlegroups.com
It is strange for I use 4.1.1 for more than 6 month, but this issue only reported mostly in recent 2 month.

2012/11/25 William Ferguson <william....@xandar.com.au>

--
 
 
 



--
BRs
EasyApps

William Ferguson

unread,
Nov 25, 2012, 8:18:55 PM11/25/12
to google-adm...@googlegroups.com
Make sure that you are passing the Activity (Context) instance to the AdView constructor and not the Application Context.

William

William Ferguson

unread,
Nov 29, 2012, 9:24:26 PM11/29/12
to google-adm...@googlegroups.com
Emanuelle,

you said you are using MopUb and integrating Admob. How do you know these errors are coming from Admob and not MopUb?

William


On Thursday, November 29, 2012 5:01:01 AM UTC+10, Emanuele Ricci wrote:
We always use Activity context (in order to let the the ad die when the activity die)

Eric Leichtenschlag

unread,
Dec 17, 2012, 12:59:37 PM12/17/12
to google-adm...@googlegroups.com
Emanuele,

Does this happen if you're using the latest version of the SDK directly? And are you sure your users are running the latest version? I've heard that the latest version is pretty free of crashes.

Thanks,
Eric

On Thursday, December 13, 2012 7:43:26 AM UTC-8, Emanuele Ricci wrote:
As I already said these crash are not coming when AdMob is disabled on mopub and they all comes when I re-enabled it from mopub.
Mopub don't have a custom implementation of admob, it's only calling the native SDK of admob that I've in my libs folder.

This crash was happining also when we was using admob directly some release ago.

chis

unread,
Mar 25, 2013, 10:49:14 AM3/25/13
to google-adm...@googlegroups.com
I'm getting this same error in my crash reports on the Play Store Console with the FLAG_ACTIVITY_NEW_TASK flag. I've never had it happen to any of my devices, so I thought it was my code the whole time.... I couldn't reproduce the rotation issue as reported above. Admittedly, I was using an old Admob SDK (6.0.1), so this may be it. But, I thought it has been my code all along and just didn't think to update Admob. I'm going to try updating the Admob SDK and see if it goes away!

On Thursday, December 20, 2012 7:19:22 AM UTC-7, Devist wrote:
I have the same issues.
I'm using Admob SDK 6.2.1 and my activity launches on "singleTask" mode.
I never seen it on my devices but it shows up frequently on my error reports.
I use it like this : 
AdView admobView = new AdView(parent, AdSize.SMART_BANNER, admobAuID);
parentView.addView(admobView);


2012년 12월 18일 화요일 오전 2시 59분 37초 UTC+9, Eric Leichtenschlag 님의 말:

Emanuele Ricci

unread,
Aug 6, 2013, 5:44:03 AM8/6/13
to google-adm...@googlegroups.com
I can assure you that this crash continue to happen also with the latest AdMob version which is 6.4.1.

Can please someone update this post with a solution?

Peter Ma

unread,
Sep 8, 2013, 7:30:10 PM9/8/13
to google-adm...@googlegroups.com
Having same problem on Admob version 6.4.1

Please fix!!!

Martín Marconcini

unread,
Feb 25, 2014, 1:26:26 PM2/25/14
to google-adm...@googlegroups.com
This is still happening with the latest Admob/Millenial. I don't know if it's really a crash or it's silently being reported, but it's top in our App. I'm considering the removal of Admob and switch to something else. It's been around forever. Has anyone found a workaround?

Eric Leichtenschlag

unread,
Feb 26, 2014, 7:37:02 PM2/26/14
to google-adm...@googlegroups.com
By "latest AdMob", do you mean 6.4.1 or Google Play services?

In Google Play services, we're seeing this issue happen on InterstitialAd if you pass an application context instead of an activity context in the constructor. That will be fixed in the next version, but the workaround for now is to pass an activity.

Thanks,
Eric
Reply all
Reply to author
Forward
0 new messages