Question

I'm trying to publish my app for 3 hours now, but I can't get the license check to work.

In my onCreate method I got this code:

// Try to use more data here. ANDROID_ID is a single point of attack.
String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
String pckName = getPackageName();

// 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, pckName, deviceId)), BASE64_PUBLIC_KEY);

mChecker.checkAccess(mLicenseCheckerCallback);

And the callback looks like this

private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
    public void allow(int policyReason) {
        if (isFinishing()) 
            return; // Don't update UI if Activity is finishing.
        // Should allow user access.
        Main.isLicensed = true;
    }

    public void dontAllow(int policyReason) {
        if (isFinishing())
            return; // Don't update UI if Activity is finishing.
        Main.isLicensed = false;
    }

    public void applicationError(int errorCode) {
        if (isFinishing())
            return; // Don't update UI if Activity is finishing.
        Main.isLicensed = false;
    }
}

Only the dontAllow method gets called. And the response code is 291.

In logcat I get "Error contacting licensing server."

  • The app is uplodaded to the developer console.

  • The public key is correct copied (without any spaces).

  • The phone (Samsung Galaxy S2 with Android 4.0.4 Stock) got internet

Any ideas?

Was it helpful?

Solution

Code looks good to me. But I have a similar problem at the moment. Did you ...

  • restarted network connection
  • restarted your phone
  • clear the data of google play store (settings -> apps -> google play store)
  • clear the data of google play services
  • logged in your device google play store with your publisher/testing account

Let me know, if solved the problem.

Thanks Best wishes

OTHER TIPS

I had this issue also when dealing with expansion files and nothing changed in my app except updating the expansion file and the manifest version #.

It took over an hour before my app would finally find and download the new expansion file. Up until that point, it just kept giving random errors like "Error contacting licensing server", then it would say that it downloaded the file (but the byte size was 1 byte, so it didn't) and the file validation would fail, etc.

As Joda said in the comments, Google is just slow sometimes. Wait a few hours and try again. Doing the steps that Christine listed in her answer can also help, but it might just be that you need to wait longer.

its internet problem. Please test it with high speed internet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top