安卓棒棒糖5.0示例许可证检查应用在模拟器(AVD)上崩溃

3

在运行Google提供的位于sdk/extras/google/play_licensing目录下的示例许可证检查应用程序时,模拟器(AVD)中的Lollipop(5.0)版本崩溃了(我没有一部运行5.0的手机)。在运行Kitkat的手机上,它可以正常工作。

在4.4 Kitkat版本中,它会发出警告:

Implicit intents with startService are not safe: Intent { act=com.android.vending.licensing.ILicensingService } 

android.content.ContextWrapper.bindService:538 com.google.android.vending.licensing.LicenseChecker.checkAccess:150 LicActivity.doCheck:126 

我不确定5.0版本是否已将其从警告变为完全错误。

我不知道如何将隐式意图调用转换为显式意图。它在LicenceChecker类中被调用。

   boolean bindResult = mContext
                            .bindService(
                                    new Intent(
                                            new String(
                                               Base64.decode("HEX_TEXT"))),
                                    this, // ServiceConnection.
                                    Context.BIND_AUTO_CREATE);

BASE64 解码成 com.android.vending.licensing.ILicensingService。

我刚刚在对话框中收到一个错误消息很遗憾,许可证检查程序已停止。

它在logcat中显示了这个消息。

java.lang.RuntimeException: Unable to instantiate application com.android.vending.VendingApplication: java.lang.ClassNotFoundException:

 Didn't find class "com.android.vending.VendingApplication" on path: DexPathList[[zip file "/system/app/LicenseChecker/LicenseChecker.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

这个问题在一段时间前已经被报道,但仍然没有解决方案。

http://code.google.com/p/android/issues/detail?id=61680


你的日志输出是什么? - 323go
我已经按照ianhanniballake的方式添加了代码以消除警告,logcat消息并报告了一个Google年前报告的错误。 - pt123
2个回答

8

添加

intent.setPackage("com.android.vending");

将你的Intent转换为Android 5.0所需的显式意图。


1
谢谢,那解决了警告问题,但该应用程序在棒棒糖上仍然崩溃,我已经在上面添加了更多细节。 - pt123
请确保按照模拟器设置说明使用Google APIs仿真器。 - ianhanniballake
它正在使用Google APIs API Level 21,其他的模拟器(4.2)都工作正常。 - pt123

1
尝试这个。
Intent serviceIntent = new Intent(
     new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")));
     serviceIntent.setPackage("com.android.vending");

     boolean bindResult = mContext
             .bindService(
               serviceIntent,
               this, // ServiceConnection.
               Context.BIND_AUTO_CREATE);

3
那是ianhanniballake在上面给出的相同答案。 - pt123
3
这恰好是我在遵循ianhanniballake建议后所使用的相同代码。 - pt123

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接