46

Our app is getting quite a few different SecurityException reports from our crash report software. Here is a stacktrace of the crash:

java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy@43fda840 (pid=17925) when registering receiver android.content.IIntentReceiver$Stub$Proxy@43fd9458
     at android.os.Parcel.readException(Parcel.java:1431)
     at android.os.Parcel.readException(Parcel.java:1385)
     at android.app.ActivityManagerProxy.registerReceiver(ActivityManagerNative.java:2466)
     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1717)
     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1685)
     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1679)
     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:453)
     at com.google.android.gms.analytics.q.v(Unknown Source)
     at com.google.android.gms.analytics.r.cF(Unknown Source)
     at com.google.android.gms.analytics.r.cH(Unknown Source)
     at com.google.android.gms.analytics.s.cO(Unknown Source)
     at com.google.android.gms.analytics.s.cP(Unknown Source)
     at com.google.android.gms.analytics.s.d(Unknown Source)
     at com.google.android.gms.analytics.s$e.run(Unknown Source)
     at java.util.Timer$TimerImpl.run(Timer.java:284)

The stack trace is always the same, except the only thing that seems to change is android.app.ApplicationThreadProxy@41da9030 (pid=9103) and android.content.IIntentReceiver$Stub$Proxy@41ee0688 have different numbers on them (is this thread id's or something?)

Now this exception seems to be linked to intent size (see the following links)

Is this the only cause? If so how is my code causing this when it seems to only come from google analytics code? Am I using GA wrong? I don't seem to be doing much besides making a tracker.

EDIT

This is how I am creating my tracker. I have a singleton tracker in my application object

Tracker appTracker;
synchronized Tracker getTracker()
{
    GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
    if (appTracker == null)
    {
        appTracker = analytics.newTracker([some key]);
        appTracker.enableAdvertisingIdCollection(true);
        analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
    }


    return appTracker;
}

Then in my BaseActivity I have the following code:

public void initAnalytics() {

    if (Global.TRACKING_ENABLED) {
        mTracker = app.getTracker();
    }
}

public void sendCommerceData(Map<String, String> params)
{
    mTracker.send(params);
}

public void sendTrackViewData(String _path)
{
    mTracker.setScreenName(_path);
    mTracker.send(new HitBuilders.AppViewBuilder().build());
}

public void sendEventData(String category, String action, String label, long value)
{
    mTracker.send(new HitBuilders.EventBuilder()
            .setCategory(category)
            .setAction(action)
            .setLabel(label)
            .setValue(value).build());
}

EDIT 2

ok here is the use of sendCommerceData:

 sendCommerceData(new HitBuilders.ItemBuilder()
                                        .setTransactionId(Integer.toString(order.orderId))
                                        .setName(orderItem.tradeTitle)
                                        .setSku(orderItem.tradeId)
                                        .setCategory(orderItem.categoryFullname)
                                        .setPrice(price)
                                        .setQuantity(orderItem.quantity)
                                        .build());

u_u

Community
  • 1
  • 1
Jason Ridge
  • 1,868
  • 15
  • 27
  • How are you creating the Tracker/sending hits to GA? – Jeffrey Mixon Nov 03 '14 at 15:40
  • @zaventh see my edited question for the way I send the hits. Im not amazingly happy with the code, but it should be working... – Jason Ridge Nov 06 '14 at 14:58
  • `sendCommerceData` looks suspicious. Are you sure you are constructing the `Map` correctly to send a valid hit? Any chance you are storing extraordinarily long `Strings` in this custom `Map`? – Jeffrey Mixon Nov 06 '14 at 16:10
  • Also, what version of Google Play Services are you importing and what is your apps `compileSdkVersion`? – Jeffrey Mixon Nov 06 '14 at 23:27
  • @JeffMixon google play services is v6.1.11 and compileSdkVersion is 19. As for the `Map` it doesnt seem outrageous, see the __Edit 2__ question for more details – Jason Ridge Nov 07 '14 at 15:28
  • `sendCommerceData` does look fine. However, your Play Services is fairly old. I think the latest is version 6.1.71 now. I'd grab that and see if the issue persists, especially when targeting 19+. – Jeffrey Mixon Nov 07 '14 at 16:00
  • google play services 6.1.11 was released on Oct 11 I believe, so it's only a month old. I've had this issue for a few months and I keep updating the library and it doesn't solve it. I will update again, but I do not think it is going to help – Jason Ridge Nov 12 '14 at 11:45
  • Having the same issue. Have you found a solution to this? Thanks. – Goran Horia Mihail Dec 17 '15 at 11:03
  • @GoranHoriaMihail Afraid not. This is for a project I no longer work on. Hope you figure it out. If you do, please add it here so others can get the help they need. – Jason Ridge Dec 22 '15 at 11:46

2 Answers2

1

It's a SecurityException means this is not happening because of our own function. (Mostly system code throw these exception).

and system uses (android.app.ApplicationThread) to register a broadcast.

Unless it is happening on all devices i can say it's because of bad GMS configuration (Google play service).

What you can do is wrap all analytics call with try catch (where you only catch Security exception).

I am not 100% sure but i will add more info after i try it my self.

Pratyush
  • 401
  • 3
  • 11
0

My guess is that you are running ProGuard on your application but haven't added the following exceptions to your proguard-rules.txt:

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}
Jeffrey Mixon
  • 12,846
  • 4
  • 32
  • 55