3

When running the the sample license check app provided by Google in sdk/extras/google/play_licensing it crashes on the Emulator(AVD) running Lollipop (5.0) (I don't have a phone running 5.0). It works fine on Phone running Kitkat.

On 4.4 Kitkat it gives a warning the

Implicit intents with startService are not safe: Intent { act=com.android.vending.licensing.ILicensingService } 

android.content.ContextWrapper.bindService:538 com.google.android.vending.licensing.LicenseChecker.checkAccess:150 LicActivity.doCheck:126 

I am not sure 5.0 they have moved it from a warning to full blown error.

I don't know how to convert the implicit intent call to an explicit one. It's being called in the LicenceChecker class

   boolean bindResult = mContext
                            .bindService(
                                    new Intent(
                                            new String(
                                               Base64.decode("HEX_TEXT"))),
                                    this, // ServiceConnection.
                                    Context.BIND_AUTO_CREATE);

BASE 64 decodes into com.android.vending.licensing.ILicensingService

I just receive an error message Unfortunately, licence checker has stopped. in a dialog box.

It is showing this message in logcat

java.lang.RuntimeException: Unable to instantiate application com.android.vending.VendingApplication: java.lang.ClassNotFoundException:

 Didn't find class "com.android.vending.VendingApplication" on path: DexPathList[[zip file "/system/app/LicenseChecker/LicenseChecker.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

It's been reported a while back but still no solution

http://code.google.com/p/android/issues/detail?id=61680

pt123
  • 2,146
  • 1
  • 32
  • 57

2 Answers2

8

Adding

intent.setPackage("com.android.vending");

to your Intent ensures that it is an explicit intent as required by Android 5.0.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • 1
    thanks that solved the warning but the app still crashes on Lollipop, I have added more details above – pt123 Nov 30 '14 at 06:16
  • Make sure you are using the Google APIs emulator as per the [emulator setup instructions](http://developer.android.com/google/play/licensing/setting-up.html#runtime-emulator) – ianhanniballake Nov 30 '14 at 06:24
  • it is using Google APIs API Level 21, all the other emulators (4.2) work fine – pt123 Nov 30 '14 at 06:29
1

Try this

Intent serviceIntent = new Intent(
     new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")));
     serviceIntent.setPackage("com.android.vending");

     boolean bindResult = mContext
             .bindService(
               serviceIntent,
               this, // ServiceConnection.
               Context.BIND_AUTO_CREATE);
NITIN DUDA
  • 192
  • 1
  • 14