Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 购买应用程序时谷歌播放未经许可的响应_Android_Google Play_Licensing_Verification_Android Lvl - Fatal编程技术网

Android 购买应用程序时谷歌播放未经许可的响应

Android 购买应用程序时谷歌播放未经许可的响应,android,google-play,licensing,verification,android-lvl,Android,Google Play,Licensing,Verification,Android Lvl,我的Android应用程序实现LVL,并在启动时检查有效的许可证。我使用的是服务器管理策略。每当我使用测试帐户,或者从Play store购买应用程序时,都会给出未经许可的响应,我的用户会非常恼火 有关守则: final Random r = new SecureRandom(); byte[] SALT = new byte[20]; r.nextBytes(SALT); lkey = "MyGooglePlayKey(hidden)"; android_i

我的Android应用程序实现LVL,并在启动时检查有效的许可证。我使用的是服务器管理策略。每当我使用测试帐户,或者从Play store购买应用程序时,都会给出未经许可的响应,我的用户会非常恼火

有关守则:

final Random r = new SecureRandom();
    byte[] SALT = new byte[20];
    r.nextBytes(SALT);

    lkey = "MyGooglePlayKey(hidden)";

    android_id = Settings.Secure.getString(getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);

    mLicenseCheckerCallback = new MyLicenseCheckerCallback();
    mChecker = new LicenseChecker(
            this, new ServerManagedPolicy(this,
            new AESObfuscator(SALT, getPackageName(), android_id)), lkey);
Settings.Secure.getString(getApplicationContext().getContentResolver(),Settings.Secure.ANDROID)是否存在此问题
?当然,授权Android文档对如何获取设备ID没有任何帮助,使用不同的方法需要另一个权限。我的方法导致Android Studio说“不建议使用getString获取设备标识符”

由于非常旧的棒棒糖bug,我的LicenseChecker类必须更改为使用明确的意图:

if (mService == null) {
            Log.i(TAG, "Binding to licensing service.");
            try {
                Intent serviceIntent = new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")))
                        .setPackage("com.android.vending");

                boolean bindResult = mContext.bindService(serviceIntent,
                        this, // ServiceConnection.
                        Context.BIND_AUTO_CREATE);
我的LVL库使用与我的应用程序相同的targetSDK/compile/minSDK:

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
useLibrary 'org.apache.http.legacy'

defaultConfig {
    minSdkVersion 17
    targetSdkVersion 26
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

dependencies {
    compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}

由于
NamePairValue
URLEncodedUtils
方法被弃用,我不得不使用这些Apache替代方法。

我不是这方面的专家,但我认为salt只是随机的,因为它对你的应用是随机的。您不会动态生成它。看

要使用AESObfuscator,请首先将其导入到活动中。声明一个私有静态最终数组来保存salt字节,并将其初始化为20个随机生成的字节

...
// Generate 20 random bytes, and put them here.
private static final byte[] SALT = new byte[] {
 -46, 65, 30, -128, -103, -57, 74, -64, 51, 88, -95,
 -45, 77, -117, -36, -113, -11, 32, -64, 89
 };
...

不幸的是,它不起作用。我已经联系了谷歌技术支持,他们告诉我他们的许可服务器正在返回许可响应。