2013-04-05 74 views
3

我正在使用Google Play許可API測試我的應用。該應用程序成功綁定到許可服務,但回調給出了錯誤6.我檢查了LicenseValidator中的錯誤代碼,這不是其中列出的錯誤代碼之一。Google Play許可 - 什麼是錯誤6?

有誰知道錯誤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(); 
    } 
} 
+0

錯誤6說的究竟是什麼? – 2013-04-05 11:07:50

+0

你說得很對,6不是其中一個記錄的返回碼。您能否向我們展示您接收並顯示此值的代碼,以防發生小錯誤? – 2013-04-05 12:00:55

+0

@PareshMayani:我面臨同樣的問題,它說logcat中的以下行。
'權限拒絕:從pid = 7605,uid = 10003訪問服務ComponentInfo {com.android.vending/com.google.android.finsky.services.LicensingService}需要com.android.vending.CHECK_LICENSE ' – MobiDev 2013-07-10 12:20:08

回答

5

好的,我已經解決了。 錯誤6不是來自LicenceValidator,它來自LicenseChecker,並且表明權限丟失。 我沒有給應用程序com.android.vending.CHECK_LICENSE權限。 當我做到了,它開始工作。

感謝您的關注,我希望這可以幫助任何犯同樣錯誤的人。

+0

您可以接受自己的答案將其從未答覆的隊列中刪除。感謝您分享解決方案。 – 2013-04-05 14:02:33