Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppLicensing fails - signature is empty string

I've implemented App-Licensing for InApp-Billing and now I'm getting Error.NOT_LICENSED and I have no idea what's wrong. The version I'm working on has not been published to the play store yet.

This is the code I use to start the licensing-process:

private void checkLicense(int retries) {
  if (retries != 5) {
    String publicKey = "YOUR KEY";
    final CdcLicenseCheckerCallback callback = new CdcLicenseCheckerCallback();
    String deviceId = mPrefsHandler.getDeviceId();
    deviceId = deviceId != null ? deviceId : UUID.randomUUID().toString();
    mPrefsHandler.setDeviceId(deviceId);
    Crashlytics.setBool("has Device-Id", deviceId != null);
    final LicenseChecker checker = new LicenseChecker(this, new ServerManagedPolicy(this,
        new AESObfuscator(new byte[] { 1, 1, ... , 1 }, getPackageName(),
            deviceId)), publicKey);
    checker.checkAccess(callback);
  }
}

I used a production variant to figure out what's happening and found that in LicenseValidator.java, the parameter signature for the method verify is an empty string, causing the sig.verify(Base64.decode(signature)) to return ERROR.NOT_LICENSED.

if (!sig.verify(Base64.decode(signature))) {
  Log.e(TAG, "Signature verification failed.");
  handleInvalidResponse();
  return;
}

I only have a hint of an idea that UUID.randomUUID().toString() might be the issue, but I have no idea, whether it actually, nor what to do here.

like image 254
TormundThunderfist Avatar asked Jan 23 '18 08:01

TormundThunderfist


Video Answer


1 Answers

Found the problem. I hadn't actually published the alpha-version to the playstore, so google play explicitly disallowed the newer version, because it didn't know about it

Solution: Check, if your installed app version is lower or equal to the latest version that was published to google play (alpha, beta or production channel)

like image 65
TormundThunderfist Avatar answered Oct 03 '22 21:10

TormundThunderfist