4

Google Play License API を使用してアプリをテストしています。アプリはライセンス サービスに正常にバインドされますが、コールバックでエラー 6 が返されます。LicenseValidator でエラー コードを確認しましたが、そこにリストされているエラー コードの 1 つではありません。

エラー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();
    }
}
4

1 に答える 1

7

わかりました、解決しました。エラー 6 は、LicenceValidator からではなく、LicenseChecker からのものであり、権限がないことを示しています。アプリに com.android.vending.CHECK_LICENSE 許可を与えていませんでした。私がしたとき、それは働き始めました。

関心をお寄せいただきありがとうございます。これが同じ間違いを犯した人の助けになることを願っています。

于 2013-04-05T13:39:36.897 に答える