AppLicensing失败 - 签名为空字符串 [英] AppLicensing fails - signature is empty string
问题描述
我为InApp-Billing实施了App-Licensing,现在我得到了 Error.NOT_LICENSED
,但我不知道有什么问题。我正在使用的版本尚未发布到Play商店。
这是我用来启动许可流程的代码:
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(有Device-Id,deviceId!= null);
final LicenseChecker checker = new LicenseChecker(this,new ServerManagedPolicy(this,$ b $ new AESObfuscator(new byte [] {1,1,...,1},getPackageName(),
deviceId )),publicKey);
checker.checkAccess(callback);
$ / code>
我使用了一个生产版本来弄清楚发生了什么,发现在 LicenseValidator.java
中,方法 verify $ c>的参数
签名
$ c>是一个空字符串,导致 sig.verify(Base64.decode(signature))
返回 ERROR.NOT_LICENSED
。
if(!sig.verify(Base64.decode(signature))){
Log.e (TAG,签名验证失败。);
handleInvalidResponse();
return;
}
我只有一点点想法: UUID .randomUUID()。toString()
可能是问题,但我不知道,不管它是真的,还是在这里做什么。
发现问题。我实际上并没有向游戏商店发布alpha版本,所以google play显然不允许使用新版本,因为它不知道它。解决方案:检查,如果您安装的应用版本低于或等于发布到谷歌播放的最新版本(alpha,beta或制作频道)
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.
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)
这篇关于AppLicensing失败 - 签名为空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!