Reputation: 4401
I am trying to implement Android License. Did everything by instructions. But when need to close app due to un license use. i get exeption:
06-12 09:11:31.384: E/LicenseChecker(383): Could not bind to service.
06-12 09:11:36.884: E/ActivityThread(383): Activity com.myapp.main.mactivity has leaked ServiceConnection com.google.android.vending.licensing.LicenseChecker@406a4428 that was originally bound here
06-12 09:11:36.884: E/ActivityThread(383): android.app.ServiceConnectionLeaked: Activity com.myapp.main.mactivity has leaked ServiceConnection com.google.android.vending.licensing.LicenseChecker@406a4428 that was originally bound here
06-12 09:11:36.884: E/ActivityThread(383): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:932)
06-12 09:11:36.884: E/ActivityThread(383): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:827)
06-12 09:11:36.884: E/ActivityThread(383): at android.app.ContextImpl.bindService(ContextImpl.java:1082)
06-12 09:11:36.884: E/ActivityThread(383): at android.content.ContextWrapper.bindService(ContextWrapper.java:370)
06-12 09:11:36.884: E/ActivityThread(383): at com.google.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:150)
What could cause this ?
onCreate method i create:
mHandler = new Handler();
// Try to use more data here. ANDROID_ID is a single point of attack.
String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
// Library calls this when it's done.
mLicenseCheckerCallback = new MyLicenseCheckerCallback();
// Construct the LicenseChecker with a policy.
mChecker = new LicenseChecker(
this, new ServerManagedPolicy(this,
new AESObfuscator(SALT, getPackageName(), deviceId)),
BASE64_PUBLIC_KEY);
doCheck();
and onDestroy:
@Override
protected void onDestroy() {
super.onDestroy();
mChecker.onDestroy();
}
So what this exception means really?
Upvotes: 2
Views: 3513
Reputation: 5904
I just ran into this as well. I was testing with an AVD Galaxy Nexus with 4.0.4.
I tried other thread's suggestions to use getApplicationContext() instead of using the current activity's context. But that did not help.
Switching to a real device did indeed fix the issue as mentioned in the comments.
The other option that may work is the following:
Upvotes: 2
Reputation: 46713
If you're using the emulator instead of a device:
The basic problem is that you aren't logged in to a valid testing account when you try to run the app on the emulator.
Upvotes: 1