Reputation: 71
I am migrating an older Android app from Eclipse to Android Studio.
Everything was working fine on older versions of Android about 3-4 years ago.
Now, when I run the app on Android 7.0 the android.vending.licensing
is producing the following (Service Intent must be explicit) Fatal Exception:
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 } }
This is my code:
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**
I am stuck with this already 2 days - any help highly appreciated.
Upvotes: 4
Views: 1871
Reputation: 131
A simple fix is to set targetSdk to 19 (or 20 not tested). For a zipped corrected set of code for this library (for Eclipse and Android Studio) see https://www.forward.com.au/AndroidProgramming/index.html#fix
Upvotes: 0
Reputation: 121
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);
For your reference, this issue happened because intent has to be explicitly defined, that means you have to call setPackage(String) and pass to function information about service or something. By doing this you say to Android what you would like to invoke, you have to do this because of Android security restrictions. By the way you have to change minSdkVersion in Licensing module build.gradle file from 3 to 4 to allow using setPackage(String) for intents.
Upvotes: 5