Android CheckLicense 始终执行“dontallow”指令方法

发布于 2024-12-09 05:52:14 字数 1846 浏览 0 评论 0原文

可能的重复:
无法让 Android Market 许可 (LVL) 可靠运行。几乎总是返回 RETRY

我在 Android 中使用 LVL 系统,我的问题是它总是执行“dontallow”方法。我正在自己的手机上测试它,该手机与我的谷歌帐户关联,因此它应该收到许可的响应(我在我的个人资料中配置了此响应)。我的代码如下:

public void ComprobarLicencia()
    {
         // Construct the LicenseCheckerCallback. The library calls this when done.
        mLicenseCheckerCallback = new ComprobadorLicencia();

        String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
        // Construct the LicenseChecker with a Policy.
        mChecker = new LicenseChecker(
            this, 
            new ServerManagedPolicy(this, new AESObfuscator(Constantes.SALT, getPackageName(), deviceId)
            ),
            Constantes.clave_publica_licencia
        );

        mChecker.checkAccess(mLicenseCheckerCallback);
    }



private class ComprobadorLicencia implements LicenseCheckerCallback 
    {
        public void allow() 
        {
            if (isFinishing()) 
            {
                // Don't update UI if Activity is finishing.
                return;
            }
        }

        public void dontAllow() 
        {
            if (isFinishing()) 
            {
                // Don't update UI if Activity is finishing.
                return;
            }
            showDialog(Constantes.dialog_licencia_incorrecta);
        }

        @Override
        public void applicationError(ApplicationErrorCode errorCode) 
        {
            if (errorCode == ApplicationErrorCode.NOT_MARKET_MANAGED)
            {
                showDialog(Constantes.dialog_licencia_incorrecta);
            }
        }
    }

我做错了什么?

Possible Duplicate:
Cannot get Android Market Licensing (LVL) working reliably. Almost always returns RETRY

I am using the LVL system in Android, and my problem is that it is always executing the "dontallow" method. I am testing it on my own phone, which has my google account associated, so it should receive a licensed response (I have this response configured on my profile). My code is the following:

public void ComprobarLicencia()
    {
         // Construct the LicenseCheckerCallback. The library calls this when done.
        mLicenseCheckerCallback = new ComprobadorLicencia();

        String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
        // Construct the LicenseChecker with a Policy.
        mChecker = new LicenseChecker(
            this, 
            new ServerManagedPolicy(this, new AESObfuscator(Constantes.SALT, getPackageName(), deviceId)
            ),
            Constantes.clave_publica_licencia
        );

        mChecker.checkAccess(mLicenseCheckerCallback);
    }



private class ComprobadorLicencia implements LicenseCheckerCallback 
    {
        public void allow() 
        {
            if (isFinishing()) 
            {
                // Don't update UI if Activity is finishing.
                return;
            }
        }

        public void dontAllow() 
        {
            if (isFinishing()) 
            {
                // Don't update UI if Activity is finishing.
                return;
            }
            showDialog(Constantes.dialog_licencia_incorrecta);
        }

        @Override
        public void applicationError(ApplicationErrorCode errorCode) 
        {
            if (errorCode == ApplicationErrorCode.NOT_MARKET_MANAGED)
            {
                showDialog(Constantes.dialog_licencia_incorrecta);
            }
        }
    }

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃兔兔 2024-12-16 05:52:14

我见过人们犯的最常见的错误是忘记将他们的应用程序上传到 Android Market(它不必发布,但至少需要作为草稿上传)。

您还必须使用与您的 Market APK 所用的签名密钥相同的签名密钥进行测试。换句话说,您需要运行应用程序的发布版本,而不是调试版本(使用调试签名密钥)。

最后,如果这是现有应用程序,请确保您已在本地 APK 和上传到 Market 的版本上增加应用程序的版本代码并请求 com.android.vending.CHECK_LICENSE 权限。 (如果您忘记执行其中任何一项操作,许可证验证服务器将不知道如何响应您的应用程序的请求。)

The most common error I've seen people make is forgetting to upload their app to Android Market (it doesn't have to be published, but at least needs to be uploaded as a draft).

You also have to be testing using the same signing key as what was used for your Market APK. In other words, you need to be running a release build of your app, not the debug build (which uses a debug signing key).

Finally, if this is an existing application, make sure you've incremented your app's version code and requested the com.android.vending.CHECK_LICENSE permission, both on your local APK and the version uploaded to Market. (If you forget to do either of those, the license verification servers won't know to respond to requests for your app.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文