PublisherAdView.loadAd() throwing SecurityException - getTasks() requires android.permission.GET_TASKS

Mark McClelland picture Mark McClelland · Mar 12, 2015 · Viewed 9.9k times · Source

Starting yesterday, March 11, I started seeing a spike in SecurityException crashes. (See stack trace below.) Are others seeing this exception as well? Searches haven't turned up anything.

My question is whether upgrading to a newer version of Play Services fixes the issue.

Here's the stack:

java.lang.SecurityException: Permission Denial: getTasks() from pid=30319, uid=10157 requires android.permission.GET_TASKS
   at android.os.Parcel.readException(Parcel.java:1474)
   at android.os.Parcel.readException(Parcel.java:1428)
   at android.app.ActivityManagerProxy.getTasks(ActivityManagerNative.java:2726)
   at android.app.ActivityManager.getRunningTasks(ActivityManager.java:791)
   at android.app.ActivityManager.getRunningTasks(ActivityManager.java:827)
   at com.google.android.gms.ads.internal.util.h.a(SourceFile:703)
   at com.google.android.gms.ads.internal.a.a(SourceFile:1634)
   at com.google.android.gms.ads.internal.a.a(SourceFile:530)
   at com.google.android.gms.ads.internal.client.t.onTransact(SourceFile:81)
   at android.os.Binder.transact(Binder.java:361)
   at com.google.android.gms.internal.bd$a$a.a()
   at com.google.android.gms.internal.bh.a()
   at com.google.android.gms.ads.doubleclick.PublisherAdView.loadAd()

I plan to publish a patch with a try/catch around the call to loadAd(). I also plan to upgrade from PlayServices 6.1.71 to 6.5.87 in the near future, but I'm reluctant to introduce that risk in a patch release unless it's a known fix.

I have reported the bug to Google here: https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/IuSQriNWKps

Edit/Clarification: I am aware that this SecurityException could be avoided by requesting the GET_TASKS permission, but I don't need that permission for my app, and I don't see why AdMob ads should, either.

I am also aware that GET_TASKS has been deprecated as of API 21, but this app targets API 19.

Answer

David Argyle Thacker picture David Argyle Thacker · Mar 12, 2015

This is either because you do not have GET_TASKS added in your manifest

<uses-permission android:name="android.permission.GET_TASKS" />

Or because it has been deprecated in API 21, see more information about how to get similar information without the GET_TASKS enter link description here