4

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.

EasyCoder
  • 71
  • 7
  • 1
    recommended reading : https://stackoverflow.com/questions/2914881/android-implicit-intents-vs-explicit-intents (implicit intent are now considered as a security risk) – ben75 Jul 04 '17 at 11:40
  • Presumably you need to update to a newer version of that library. You are not calling `bindService()` yourself; the library would appear to be doing that. – CommonsWare Jul 04 '17 at 11:52
  • LicenseCheckerCallback library? – EasyCoder Jul 04 '17 at 13:09
  • I think I found it in the LicenseChecker.java: boolean bindResult = mContext.bindService( new Intent(ILicensingService.class.getName()), this, // ServiceConnection.Context.BIND_AUTO_CREATE); How this needs to be changed to make the Intent Explicit? – EasyCoder Jul 04 '17 at 14:32
  • @CommonsWare , I have updated to the newest version of MarketLicencing libraries, and the result is the same: 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 [...] java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.android.vending.licensing.ILicensingService launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } } – EasyCoder Jul 16 '17 at 16:51
  • Since I don't use this library, I have no way to help you further. See what other support options Google offers for this library. – CommonsWare Jul 16 '17 at 17:12

2 Answers2

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

O.G.
  • 101
  • 6
0

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

matthew
  • 131
  • 4