Android 授权服务器出现问题

发布于 2024-09-19 17:42:00 字数 774 浏览 4 评论 0原文

我尝试使用Android的新许可服务,但遇到了一些麻烦。我在主活动中的代码如下所示:(

  mLicenseCheckerCallback = new MyLicenseCheckerCallback();

  String deviceId = Secure.getString(MainTabActivity.this.getContentResolver(), Secure.ANDROID_ID);

    mChecker = new LicenseChecker(
            MainTabActivity.this, new ServerManagedPolicy(MainTabActivity.this,
                new AESObfuscator(SALT, getPackageName(), deviceId)),
            BASE64_PUBLIC_KEY  
            );

        mChecker.checkAccess(mLicenseCheckerCallback);

基本上只是 Android 在线文档中显示的代码。如果允许,回调就会通过,如果不允许,则显示一条消息并退出应用程序。到目前为止一切都很好。

问题是它在调试器中工作正常,但是当我将其发布到市场并升级我的应用程序时(我已经使用我的个人 gmail 帐户购买了我的应用程序的一个版本,所以我是合法用户),我收到错误我的应用程序未获得许可。我什至已将我的个人 Gmail 地址添加到我的市场配置文件中的白名单中,并将状态设置为“已许可”,但仍然出现错误,您有什么建议吗?

I've tried to use the new license service of Android and I am facing some troubles. My code in the main activity looks like this:

  mLicenseCheckerCallback = new MyLicenseCheckerCallback();

  String deviceId = Secure.getString(MainTabActivity.this.getContentResolver(), Secure.ANDROID_ID);

    mChecker = new LicenseChecker(
            MainTabActivity.this, new ServerManagedPolicy(MainTabActivity.this,
                new AESObfuscator(SALT, getPackageName(), deviceId)),
            BASE64_PUBLIC_KEY  
            );

        mChecker.checkAccess(mLicenseCheckerCallback);

(basically just the shown code of the Android online documentation. The callback passes through if it's allowed and if it's not it displays a message and quits the app. So far so good.

The problem is that it works fine in the debugger, but when I publish it to the market and upgrade my app (I've purchased a version of my app with my personal gmail-accout, so I am a legitimate user) I get the error that the my app is not licensed. I've even added my personal gmail address to the whitelist in my market-profile and set the status to "LICENSED" but it still comes up with the error. Do you have any suggestions ?

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

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

发布评论

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

评论(2

╰ゝ天使的微笑 2024-09-26 17:42:00

许可服务的回调有时会在几秒钟内不会发生 - 如果存在网络延迟,情况会更糟。在成功尝试后,它通常会在服务中缓存答案,以帮助减少以后应用程序启动时的延迟。

您很可能需要将关闭应用程序(或禁用功能)的逻辑移至 UI 体验的后期。

我还遇到过一些用户误报的情况,如果他们关闭应用程序并稍后重试,这些误报就会得到纠正。

The callback from the licensing service sometimes doesn't happen for several seconds - worse if there is network lag. It will generally cache the answer in the service after a successful attempt to help reduce that lag on later app starts.

You most likely need to move the logic for closing the app (or disabling features) to later in the UI experience.

I've also had a few false negatives for users that were corrected if they closed the app and tried again later.

暗藏城府 2024-09-26 17:42:00

我遇到了同样的问题并添加

<uses-permission
        android:name="com.android.vending.CHECK_LICENSE"></uses-permission> 

到清单中,为我解决了问题!

I had the same issue and added

<uses-permission
        android:name="com.android.vending.CHECK_LICENSE"></uses-permission> 

to the manifest, did the trick for me!

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