Xamarin Google Licensing response mixed up

2019-08-25 07:23发布

I'm developing a app using xamarin and a plug-in port of Google Licensing. And I can't get it to work... I set 3 testers to reply licenced in the developer console ( including myself ) and on those accounts I get NotLicenced response... Even logged in with my publisher account.

his is the plugin i'm using: https://github.com/mattleibow/Android.Play.ExpansionLibrary

this is the code I'm using:

bool internet = Task.Run(CheckNET).Result;

// Construct the LicenseChecker with a policy.
var obfuscator = new AesObfuscator(Salt, this.PackageName, Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId));
var policy = new ServerManagedPolicy(this, obfuscator);
this.checker = new LicenseChecker(this, policy, "Here is my API public key");

if (internet)
{
     checker.CheckAccess(this);
}

I've fixed all application error messages in within the first tries (permissions and then NotMarketManaged) and now I'm stuck getting NotLicensed...

So the communication is working, just the License response isn't comming back as it should be for the emails listed in License Testing.

So.. with more testing it a bit strange... I've set ERROR_NON_MATCHING_UID as default response for testers and it did reply that exact error.... but when I changed back to Licensed I got NOT_LICENSED response...

After that it got way stranger... I've played a bit with the response options and this is what responses I got from Google Licensing server:

Google Console set to:             Server Response:
Licensed                            Not_licensed
Licensed_old_Key                    Not_Licensed
Not_Licensed                        Not_licensed
Error_server_failuere               LICENSED
Error_contacting_server             Licensed
Error_invalid_packagename           InvalidPackageName
error_nonmatching_uid               NonMatchingUid

so... can anyone explain what is going on? Could the plugin that I'm using be analysing the codes wrongly?

I've checked the plugin code and this is what I found that it is using these response codes:

Licensed = 0x0, 
NotLicensed = 0x1, 
LicensedOldKey = 0x2, 
NotMarketManaged = 0x3, 
ServerFailure = 0x4, 
OverQuota = 0x5, 
ErrorContactingServer = 0x101, 
InvalidPackageName = 0x102, 
NonMatchingUid = 0x103

can anyone confirm if these are the correct codes that Google Licensing replies?

1条回答
做自己的国王
2楼-- · 2019-08-25 08:00

The Java LicenseValidator.java based values from Google Play Licensing Library, rev 2:

// Server response codes.
private static final int LICENSED = 0x0;
private static final int NOT_LICENSED = 0x1;
private static final int LICENSED_OLD_KEY = 0x2;
private static final int ERROR_NOT_MARKET_MANAGED = 0x3;
private static final int ERROR_SERVER_FAILURE = 0x4;
private static final int ERROR_OVER_QUOTA = 0x5;

private static final int ERROR_CONTACTING_SERVER = 0x101;
private static final int ERROR_INVALID_PACKAGE_NAME = 0x102;
private static final int ERROR_NON_MATCHING_UID = 0x103;

They match the ones from the C# Android.Play.ExpansionLibrary

查看更多
登录 后发表回答