什么是5.0许可错误的最佳解决方案?

时间:2015-04-11 22:21:39

标签: android android-5.0-lollipop android-lvl

所以我的所有应用程序在5.0上运行时都会遇到此异常。 。

java.lang.IllegalArgumentException:Service Intent必须是显式的:Intent {act = com.android.vending.licensing.ILicensingService}

在谷歌搜索后,我发现这是由LicenseChecker.java中的Google Licensing代码中的错误引起的,但建议的更改有点不同,所以我不知道该怎么做。它让我感到震惊,我们应该为Googles代码制作mod。

我的LicenseChecker.java中的可疑代码是......

        Log.i(TAG, "Binding to licensing service.");
        try {
            boolean bindResult = mContext
                    .bindService(
                            new Intent(
                                    new String(
                                            Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))),
                            this, // ServiceConnection.
                            Context.BIND_AUTO_CREATE);

我们应该添加

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

该代码中的某个地方。

所以我的问题是(1)这真的是修复吗? (2)如果是这样,修改后的代码到底应该是什么样的? 谢谢, 迪安

1 个答案:

答案 0 :(得分:6)

  

这真的是修复吗?

setPackage()足以超越API Level 21+的隐含 - Intent限制。这是否是正确的包装,我不能说。

  

修改后的代码到底应该是什么样的?

替换:

new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")))

使用:

new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")))
  .setPackage("com.android.vending")