Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
97 views
in Technique[技术] by (71.8m points)

android - SecurityException: Parcel.readException coming from google analytics code

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

question from:https://stackoverflow.com/questions/26379516/securityexception-parcel-readexception-coming-from-google-analytics-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...