Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app licencing fatal exception: Service Intent must be explicit

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.

like image 694
EasyCoder Avatar asked Sep 19 '25 23:09

EasyCoder


1 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 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.

like image 185
O.G. Avatar answered Sep 21 '25 13:09

O.G.