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,982 views
Skip to first unread message

Emanuel Moecklin

unread,
May 7, 2012, 9:47:37 PM5/7/12
to google-adm...@googlegroups.com
Hi Admob

With 4.31 the exception 

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:744)

                at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)

                at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:230)

                at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:337)

                at android.os.Handler.dispatchMessage(Handler.java:99)

                at android.os.Looper.loop(Looper.java:130)

                at android.app.ActivityThread.main(ActivityThread.java:3687)

                at java.lang.reflect.Method.invokeNative(Native Method)

                at java.lang.reflect.Method.invoke(Method.java:507)

                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)

                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)

                at dalvik.system.NativeStart.main(Native Method)

has disappeared almost completely. Unfortunately with 6.0.0 the same exception has re-surfaced.
I published my first app with 6.0.0 including mediation for Admob, MobFox and InMobi last Friday and the number of exceptions of that type has increased considerably:
  • 5/1/12: 0 
  • 5/2 /12 : 1 
  • 5/3 /12 : 0 
  • 5/4 /12 : 1 (Release Day) 
  • 5/5 /12 : 11
  • 5/6 /12 : 13 
  • 5/7 /12 : 27 (as of 9pm)
I fear this is just the beginning since it has been only 4 days since the release and most users are still on the old version.
As a consequence I won't release my other apps with the new SDK and If the numbers keep increasing at that rate I will have to consider going back to 4.3.1.
Obviously it's possible to deal with the many WebView quirks to prevent this exception otherwise 4.3.1 wouldn't have worked so well.
I hope there will be a 6.0.1 with a fix rather sooner than later. Please Admob Dev Support convince your PMs that new features can wait until there's a stable release, noone wants to wait as long again as we had to wait for the 4.3.1 release...

Thanks
Emanuel Moecklin
1gravity LLC

Eric Leichtenschlag

unread,
May 9, 2012, 3:18:11 PM5/9/12
to google-adm...@googlegroups.com
Hey Emanuel,

Is this reproducible at all?  Any particular devices that this occurs on?  Or are you reporting these directly from Flurry?

Thanks,
Eric

Emanuel Moecklin

unread,
May 9, 2012, 5:40:59 PM5/9/12
to google-adm...@googlegroups.com
It's not reproducible.
There seems to be no pattern related to devices. I got all kinds of brands and Android versions from 2.x up to 4.0.4. No 1.6 devices so far ;-). 
I'm reporting by other means than Flurry, more reliable ones with more detailed information.

Thanks for looking into this
Emanuel

Emanuel Moecklin

unread,
May 10, 2012, 10:29:47 AM5/10/12
to Google AdMob Ads Developers
Hi Eric

For whatever reason my reply shows as being deleted. Anyway here I go
again.
No it's not reproducible and there doesn't seem to be a pattern
related to devices, brands, Android version etc.
I get the exception from all kinds of devices, versions from 2.x up to
4.0.4 (no 1.6 devices so far ;-).
I do use Flurry but I use other "means" to report exceptions, more
reliable and detailed reports.

I'm not sure if the WebView is always managed by the Admob SDK or if
the Mobfox and/or InMobi SDKs are responsible for showing their ads?
In the second case we might have to consider the possibility that it's
the MobFox/InMobi SDK causing these exceptions.
Would be helpful if you could check on your end what SDK is actually
showing the ads.

Thanks for looking into this
Emanuel

On Wednesday, May 9, 2012 3:18:11 PM UTC-4, Eric Leichtenschlag wrote:

Eric Leichtenschlag

unread,
May 14, 2012, 4:47:56 PM5/14/12
to google-adm...@googlegroups.com
Hey Emanuel,

Their adapter code generates the IMAdView, for example, and AdMob's AdView essentially becomes a container for the IMAdView, or any other ad network view that is shown in Mediation.  So the mediated ad network controls the WebView and their creative.  We still own the activity though.

Have you used MobFox or InMobi at all before AdMob Mediation rolled out?  If so, were there any occurrences of this issue when using them directly?  If not, the issue is likely on our end.  I've filed a bug for this.

Thanks,
Eric

Emanuel Moecklin

unread,
May 14, 2012, 8:32:24 PM5/14/12
to google-adm...@googlegroups.com
Hi Eric

I turned off mediation completely.
If the exception still shows it's Admob's SDK, if they don't then I'll turn on each network one by one and we'll know.
I'll let you know the outcome of this little experiment.

Cheers
EManuel

Emanuel Moecklin

unread,
May 15, 2012, 11:37:43 PM5/15/12
to Google AdMob Ads Developers
Hi Eric

Even with MobFox and InMobi turned off the exception shows, although I
got less than the days before with all three networks turned on.
So I think it's safe to assume that at least a good number of these
exception are caused by the Admob SDK.

Thanks for looking into this and hopefully we get a fix soon.

Cheers
Emanuel

On May 14, 4:47 pm, Eric Leichtenschlag <eleichtens...@google.com>
wrote:

ng

unread,
May 19, 2012, 11:48:43 AM5/19/12
to google-adm...@googlegroups.com
Hello,

Same problem here with 6.0, no mediation:

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:644)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:228)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:323)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)

Regards

Emanuel Moecklin

unread,
May 23, 2012, 9:39:21 AM5/23/12
to Google AdMob Ads Developers
Hi Eric

I look like this will take a while to fix (as usual I have to say...)
so I'll revert back to the stable 4.3.1.
You guys should have a test app published on the market with a couple
to tens of thousands of users to test your releases before you hit the
real world with it (meaning the thousands of apps running Admob with
millions of users).
I'm releasing with just one of my apps first to see how stable the new
features really are (like Admob mediation) before I roll it out to my
more successful apps. If I can do it Admob should definitely be able
to do it (having more resources and all that...).

I also wonder how a relatively small piece of code (certainly less
than 10% of my code base) can cause 80% of my crashes. And no it's not
just Webkit/WebView, I'm using those intensively too.
Sorry to sound disappointed but honestly I really am. Messing up a
release happens to everyone but it seems to be happening with (almost)
every Admob release. The only stable one I used in the last two years
is 4.3.1.

Best Regards
Emanuel

digipom

unread,
Jul 19, 2012, 9:05:53 AM7/19/12
to google-adm...@googlegroups.com
Hi all,

I'm getting the same crash with the latest Admob SDK; any timeline on a fix? Does Admob have a bug tracker we can follow?

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:947)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:283)
at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:278)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:381)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4517)
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:993)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
at dalvik.system.NativeStart.main(Native Method) 

Eric Leichtenschlag

unread,
Aug 9, 2012, 12:55:36 PM8/9/12
to google-adm...@googlegroups.com
Hey Emanuele,

Try using SDK v6.1.0.  We've made a change that should fix this issue.

Cheers,
Eric


On Wed, Aug 8, 2012 at 7:52 AM, Emanuele Ricci <e.r...@designfuture.it> wrote:
Hi guys, this is the code of my crash


Package: com.musixmatch.android.lyrify
Version: 2012080800
Android: 4.0.4
Manufacturer: samsung
Model: GT-N7000
Date: Wed Aug 08 16:37:17 CEST 2012

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:922)
	at android.content.ContextWrapper.startActivity(ContextWrapper.java:283)
	at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:246)
	at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:349)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:4511)
	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:980)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
	at dalvik.system.NativeStart.main(Native Method)

And I'm using this version of AdMob: GoogleAdMobAdsSdk-6.0.1.jar

is there a way to fix this? Thanks

--
 
 
  

Emanuel Moecklin

unread,
Aug 21, 2012, 7:51:30 AM8/21/12
to Google AdMob Ads Developers
Hi Eric

The exception has completely disappeared with 6.1.0 while I still get
the error with 6.0.0.
BTW the amount of FLAG_ACTIVITY_NEW_TASK errors with 4.3.1 is
enormous. There _had_ to be a change in displayed ads of some kind.

Thanks for the fix and please keep it that way in future releases.

Best Regards
Emanuel Moecklin
Reply all
Reply to author
Forward
0 new messages