android - Google Play 许可证 - 错误 6 是什么?

标签 android android-lvl

我正在使用 Google Play License API 测试我的应用。该应用程序成功绑定(bind)到许可服务,但回调给出错误 6。我已经检查了 LicenseValidator 中的错误代码,这不是那里列出的错误代码之一。

有谁知道错误6是什么意思?

public class MyActivity extends FragmentActivity
{

    private static final String BASE64_PUBLIC_KEY = "ZZZZ";

    private static final byte[] SALT = new byte[] {
        XXXX
    };

    private LicenseCheckerCallback mLicenseCheckerCallback;
    private LicenseChecker mChecker;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);

        String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

        // Library calls this when it's done.
        mLicenseCheckerCallback = new YAHLicenseCheckerCallback();

        // Construct the LicenseChecker with a policy, obfuscator and public key
        mChecker = new LicenseChecker(this, 
                new ServerManagedPolicy(this,
                new AESObfuscator(SALT, getPackageName(), deviceId)),
                BASE64_PUBLIC_KEY);
        mChecker.checkAccess(mLicenseCheckerCallback);
    }

    private class YAHLicenseCheckerCallback implements LicenseCheckerCallback {
        public void allow(int policyReason) {
            Log.d(tag,"License - allowed");

            if (isFinishing()) {
                // Don't do anything if Activity is finishing.
                return;
            }
            // Should allow user access.

        }

        public void dontAllow(int policyReason) {
            Log.d(tag,"License - not allowed");

            if (isFinishing()) {
                // Don't do anything UI if Activity is finishing.
                return;
            }

            // Should not allow access. In most cases, the app should assume
            // the user has access unless it encounters this. If it does,
            // the app should inform the user of their unlicensed ways
            // and then either shut down the app or limit the user to a
            // restricted set of features.

        }

        public void applicationError(int errorCode) {

            Log.d(tag,"License - application error code "+errorCode);

            if (isFinishing()) {
                // Don't update UI if Activity is finishing.
                return;
            }
            // This is a polite way of saying the developer made a mistake
            // while setting up or calling the license checker library.
            // Please examine the error code and fix the error.

        }
    }

    @Override
    protected void onDestroy()
    {
    mChecker.onDestroy();
    super.onDestroy();
    }
}

最佳答案

好的,我已经解决了。 错误 6 不是来自 LicenceValidator,而是来自 LicenseChecker,表示缺少权限。 我没有给应用程序 com.android.vending.CHECK_LICENSE 权限。 当我这样做时,它开始工作了。

感谢您的关注,希望这对犯同样错误的人有所帮助。

关于android - Google Play 许可证 - 错误 6 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15832310/

相关文章:

Android:如何扭曲图像?

java - Android TCP 连接(多客户端)

Android - 定时器功能和 alertDialog

android - Google Play LVL 许可证检查 "package"或 "public key"是特定的吗?

Android:我应该在每次打开应用程序时调用 LicenseChecker 吗?

android - 如何启动预填了 "to"字段的电子邮件应用程序?

android - 将 WebView 显示为 AlertDialog 内容

android - 是否可以合并现有的精简版和完整版(在精简版中加上应用内结算)?

android - 如何将(已购买的)Android 应用程序作为礼物送给客户?

android - 购买应用时 Google Play 未经许可的响应