Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 787
Mark McClelland Avatar asked Mar 12 '15 19:03

Mark McClelland


2 Answers

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

like image 114
Andrea Thacker Avatar answered Oct 13 '22 05:10

Andrea Thacker


Google reports that a fix has been released, and that we "should see the incidence rate of that particular exception decrease, and within a week disappear entirely". Furthermore, it is a server-side fix, and does not require an upgrade to Play Services.

The full conversation is available here: https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/IuSQriNWKps

Meanwhile, you can either catch the SecurityException and allow the call to loadAd() to fail, or -- as @dthacker noted -- you can include the GET_TASKS permission in AndroidManifest.xml. If you choose to include this permission, note that you remove it once you target API 21, as the permission is no longer enforced (apparently because they have reduced the amount of information provided, now that document-oriented tasks could result in privacy leaks).

like image 20
Mark McClelland Avatar answered Oct 13 '22 05:10

Mark McClelland