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

Dea*_*ely 1 android android-lvl android-5.0-lollipop

所以我的所有应用程序在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);
Run Code Online (Sandbox Code Playgroud)

我们应该补充一下

serviceIntent.setPackage("com.android.vending");
Run Code Online (Sandbox Code Playgroud)

代码中的某个地方.

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

Com*_*are 6

这真的是修复吗?

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

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

更换:

new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")))
Run Code Online (Sandbox Code Playgroud)

有:

new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")))
  .setPackage("com.android.vending")
Run Code Online (Sandbox Code Playgroud)