Android App Licensing Exception. Initial service should be explicit.

I am migrating an old Android app from Eclipse to Android Studio.

Everything works fine in older Android versions about 3-4 years ago.

Now when I run my app on Android 7.0 it android.vending.licensing

throws 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've been stuck with this for 2 days now - any help was much appreciated.

+3


source to share


2 answers


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 came about because the intent had to be explicitly defined, which means you need to call setPackage (String) and pass information about the service functions or whatever. By doing this, you are telling Android what you would like to call, you must do so due to Android security restrictions. By the way, you need to change the minSdkVersion file in your build.gradle file for licensing module 3 through 4 to allow the use of setPackage (String) for intents.

+1


source


An easy solution 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



0


source







All Articles