Android应用内结算和Proguard(未知来源)

时间:2013-08-21 13:21:39

标签: android proguard in-app-billing

我正在使用Google和Proguard的应用内结算服务。我作为Proguard使用的配置文件是... / sdk / tools / proguard / proguard-android.txt

中的配置文件

Google在此处说:http://developer.android.com/google/play/billing/billing_best_practices.html我在配置文件中添加了以下行:

-keep class com.android.vending.billing.**

我也在使用Google的IAB更新文件:https://code.google.com/p/marketbilling/source/detail?r=7ec85a9b619fc5f85023bc8125e7e6b1ab4dd69f

问题在于,有时用户使用此堆栈跟踪报告随机崩溃:

E/AndroidRuntime: FATAL EXCEPTION: Thread-455
java.lang.NullPointerException
    at com.xx.xxxx.util.IabHelper.startSetup(Unknown Source)
    at com.xx.xxxx.util.IabHelper$2.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:856)

它也发生在我的设备上(只是打开应用程序)但今天只发生过一次。

我不确定是否存在Google文件(IAB)的问题或Proguard配置文件中缺少某些内容。

6 个答案:

答案 0 :(得分:4)

添加以下字符串

-keep class com.android.vending.billing.**

到ProGuard配置告诉他不要混淆该软件包。

异常来自com.xx.xxxx.util.IabHelper,因此您可以尝试添加类似

的内容
-keep class com.xx.xxxx.util.IabHelper.**

在没有ProGuard的情况下保持您的包装。

答案 1 :(得分:2)

您的proguard配置是正确的。我甚至允许在我的应用程序中对生成的com.android.vending.billing.IInAppBillingService进行模糊处理,一切正常。

关于IabHelper课程。我不建议“按原样”使用它。首先,它被证明是错误的。其次,即使在混淆时,它也可能被自动工具攻击。我建议根据IabHelper编写自己的类,并为它编写junit测试。这也是我为我的项目所做的。

答案 2 :(得分:2)

IabHelpers中的这一行是startSetup()

mContext.getPackageManager()
                .queryIntentServices(serviceIntent, 0);

有时可以返回null,因此在检查列表是否为空时,您将获得nullpointer。

在执行任何其他操作之前,我只是将其修改为检查null;

List<ResolveInfo> queryIntentServices = mContext.getPackageManager()
            .queryIntentServices(serviceIntent, 0);
    if (queryIntentServices != null && !queryIntentServices.isEmpty()) {
        // service available to handle that Intent
        mContext.bindService(serviceIntent, mServiceConn,
                Context.BIND_AUTO_CREATE);
    }else ...

答案 3 :(得分:0)

只需将此添加到您的proguard配置文件中以保留行号,然后您就不会知道来源:

-keepattributes签名,SourceFile, LineNumberTable

答案 4 :(得分:0)

这对我有用

-keep class com.android.vending.** { *; }

答案 5 :(得分:0)

有关InApp计费ProGuard规则,请参考Verify a purchase on a device -> Below warning

因为它仅定义了InApp结算的一条规则,

-keep class com.android.vending.billing.**