Android CheckLicense is always executing the “dontallow” method [duplicate]

有些话、适合烂在心里 提交于 2019-12-11 18:17:07

问题


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?


回答1:


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.)



来源:https://stackoverflow.com/questions/7743430/android-checklicense-is-always-executing-the-dontallow-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!