SecurityException: Parcel.readException 来自谷歌分析代码 [英] SecurityException: Parcel.readException coming from google analytics code

查看:21
本文介绍了SecurityException: Parcel.readException 来自谷歌分析代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序从我们的崩溃报告软件中获得了很多不同的 SecurityException 报告.这是崩溃的堆栈跟踪:

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)

堆栈跟踪始终相同,唯一似乎发生变化的是android.app.ApplicationThreadProxy@41da9030 (pid=9103)android.content.IIntentReceiver$Stub$Proxy@41ee0688 上面有不同的数字(这是线程 ID 还是什么?)

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)

这是唯一的原因吗?如果是这样,当我的代码似乎仅来自 google analytics 代码时,它是如何导致这种情况的?我使用 GA 错了吗?除了制作跟踪器之外,我似乎没有做太多事情.

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.

编辑

这就是我创建跟踪器的方式.我的应用程序对象中有一个 singleton 跟踪器

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

然后在我的 BaseActivity 中,我有以下代码:

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

编辑 2

好的,这里是使用 sendCommerceData:

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

推荐答案

这是一个 SecurityException 意味着这不会发生,因为我们自己的功能.(主要是系统代码抛出这些异常).

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

并且系统使用 (android.app.ApplicationThread) 来注册广播.

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

除非它发生在所有设备上,否则我可以说这是因为 GMS 配置不当(Google Play 服务).

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

您可以做的是使用 try catch 包装所有分析调用(您只捕获安全异常).

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

我不是 100% 确定,但我会在我自己尝试后添加更多信息.

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

这篇关于SecurityException: Parcel.readException 来自谷歌分析代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆