Android CheckLicense始终执行“dontallow”方法

时间:2011-10-12 16:35:57

标签: android android-lvl

  

可能重复:
  Cannot get Android Market Licensing (LVL) working reliably. Almost always returns 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);
            }
        }
    }

我做错了什么?

1 个答案:

答案 0 :(得分:1)

我见过的最常见的错误是忘记将他们的应用上传到Android电子市场(不需要发布,但至少需要上传为草稿)。

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

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