我正在将旧的Android应用从Eclipse迁移到Android Studio。
大约3 - 4年前,旧版Android上的一切都运行良好。
现在,当我在Android 7.0上运行应用程序时,android.vending.licensing
正在生成以下内容(Service Intent必须是显式的)致命异常:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=110, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } (has extras) }} to activity {HexagoniaGalaxyS7.hexagoniagalaxys7.apk/hexagoniagalaxys7.apk.HexagoniaActivity}: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.android.vending.licensing.ILicensingService launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
Caused by: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.android.vending.licensing.ILicensingService launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
这是我的代码:
String deviceId = tManager.getDeviceId();
licenseCheckerCallback = new HexagoniaLicenseCheckerCallback();
licenceChecker = new LicenseChecker(this, new ServerManagedPolicy(this, new AESObfuscator(JUMBLE, getPackageName(), deviceId)), BASE64_PUBLIC_KEY);
licenceChecker.checkAccess(licenseCheckerCallback); // **IT CRASHES ON THIS LINE**
我已经坚持了2天 - 任何帮助都非常感谢。
答案 0 :(得分:1)
Intent intent = new Intent(new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))));
intent.setPackage("com.android.vending");
boolean bindResult = mContext
.bindService(
intent,
this, // ServiceConnection.
Context.BIND_AUTO_CREATE);
供您参考,出现此问题是因为必须明确定义intent,这意味着您必须调用setPackage(String)并传递给有关服务或其他内容的函数信息。 通过这样做,您可以向Android说出您想要调用的内容,因为Android安全限制,您必须执行此操作。顺便说一下,您必须将Licensing模块build.gradle文件中的minSdkVersion从3更改为4,以允许使用setPackage(String)作为意图。
答案 1 :(得分:0)
一个简单的解决方法是将targetSdk设置为19(或20未测试)。对于此库的压缩校正代码集(适用于Eclipse和Android Studio),请参阅 https://www.forward.com.au/AndroidProgramming/index.html#fix