Android 模拟器上的市场许可 API 问题

发布于 2024-10-17 12:48:45 字数 4529 浏览 1 评论 0原文

我有一个使用许可证检查 API 的 Android 应用程序。我已经使用 Google API 设置了 API 级别 8、9 和 10 的模拟器 AVD。我的应用程序在 8 级 AVD 上运行良好,但在 9 级和 10 级 AVD 上却严重失败。这是一个典型的 logcat 序列:(

02-14 17:43:55.815: INFO/LicenseChecker(448): Binding to licensing service.
02-14 17:43:55.935: WARN/ActivityManager(65): Unable to start service Intent { act=com.android.vending.licensing.ILicensingService }: not found
02-14 17:43:55.935: ERROR/LicenseChecker(448): Could not bind to service.
02-14 17:44:00.625: INFO/ActivityManager(65): Displayed com.zigzagworld.tehillim/.Tehillim: +2m1s448ms (total +5m43s546ms)
02-14 17:44:01.085: INFO/ARMAssembler(65): generated scanline__00000177:03515104_00001002_00000000 [ 87 ipp] (110 ins) at [0x439de6f0:0x439de8a8] in 5603158 ns
02-14 17:44:18.025: INFO/InputReader(65): Device reconfigured: id=0x0, name=qwerty, display size is now 320x480
02-14 17:44:18.025: WARN/InputReader(65):   Touch device did not report support for X or Y axis!
02-14 17:44:19.005: WARN/InputManagerService(65): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40945580
02-14 17:44:20.805: ERROR/ActivityThread(448): Activity com.zigzagworld.tehillim.Tehillim has leaked ServiceConnection com.android.vending.licensing.LicenseChecker@4051ba58 that was originally bound here
02-14 17:44:20.805: ERROR/ActivityThread(448): android.app.ServiceConnectionLeaked: Activity com.zigzagworld.tehillim.Tehillim has leaked ServiceConnection com.android.vending.licensing.LicenseChecker@4051ba58 that was originally bound here
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:938)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:833)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ContextImpl.bindService(ContextImpl.java:864)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at com.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:143)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at com.zigzagworld.tehillim.Tehillim.onCreate(Tehillim.java:76)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.os.Looper.loop(Looper.java:123)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread.main(ActivityThread.java:3647)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at java.lang.reflect.Method.invokeNative(Native Method)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at java.lang.reflect.Method.invoke(Method.java:507)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at dalvik.system.NativeStart.main(Native Method)
02-14 17:44:20.835: WARN/ActivityManager(65): Unbind failed: could not find connection for android.os.BinderProxy@40774fd0

我已验证我的测试帐户已在所有模拟器中设置,并且我已将开发人员控制台设置为返回测试帐户的 LICENSED 响应。)发生有关泄漏连接的错误在我的 LicenseCheckerCallback 中完成 dontAllow() 处理后。

我的代码很普通。我在 onCreate() 中运行以下代码:

String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
AESObfuscator ob = new AESObfuscator(SALT, getPackageName(), deviceId);
LicenseChecker checker = new LicenseChecker(this,
    new ServerManagedPolicy(this, ob), BASE64_PUBLIC_KEY);
checker.checkAccess(this);

API 8 之后许可代码是否发生了变化?除了 API 8 之外,还有其他人能够测试许可吗?

更新:Google 提供的市场许可示例应用程序也会出现同样的问题。

I have an Android app that uses the license checking API. I've set up emulator AVDs with the Google APIs for API levels 8, 9, and 10. My app works fine with the level 8 AVD but fails miserably with the level 9 and 10 AVDs. Here is a typical logcat sequence:

02-14 17:43:55.815: INFO/LicenseChecker(448): Binding to licensing service.
02-14 17:43:55.935: WARN/ActivityManager(65): Unable to start service Intent { act=com.android.vending.licensing.ILicensingService }: not found
02-14 17:43:55.935: ERROR/LicenseChecker(448): Could not bind to service.
02-14 17:44:00.625: INFO/ActivityManager(65): Displayed com.zigzagworld.tehillim/.Tehillim: +2m1s448ms (total +5m43s546ms)
02-14 17:44:01.085: INFO/ARMAssembler(65): generated scanline__00000177:03515104_00001002_00000000 [ 87 ipp] (110 ins) at [0x439de6f0:0x439de8a8] in 5603158 ns
02-14 17:44:18.025: INFO/InputReader(65): Device reconfigured: id=0x0, name=qwerty, display size is now 320x480
02-14 17:44:18.025: WARN/InputReader(65):   Touch device did not report support for X or Y axis!
02-14 17:44:19.005: WARN/InputManagerService(65): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40945580
02-14 17:44:20.805: ERROR/ActivityThread(448): Activity com.zigzagworld.tehillim.Tehillim has leaked ServiceConnection com.android.vending.licensing.LicenseChecker@4051ba58 that was originally bound here
02-14 17:44:20.805: ERROR/ActivityThread(448): android.app.ServiceConnectionLeaked: Activity com.zigzagworld.tehillim.Tehillim has leaked ServiceConnection com.android.vending.licensing.LicenseChecker@4051ba58 that was originally bound here
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:938)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:833)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ContextImpl.bindService(ContextImpl.java:864)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at com.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:143)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at com.zigzagworld.tehillim.Tehillim.onCreate(Tehillim.java:76)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.os.Looper.loop(Looper.java:123)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at android.app.ActivityThread.main(ActivityThread.java:3647)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at java.lang.reflect.Method.invokeNative(Native Method)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at java.lang.reflect.Method.invoke(Method.java:507)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-14 17:44:20.805: ERROR/ActivityThread(448):     at dalvik.system.NativeStart.main(Native Method)
02-14 17:44:20.835: WARN/ActivityManager(65): Unbind failed: could not find connection for android.os.BinderProxy@40774fd0

(I've verified that my test account is set up in all emulators and I've set up the developer console to return a response of LICENSED for the test account.) The error about leaking a connection occurs after I complete the dontAllow() processing in my LicenseCheckerCallback.

My code is pretty vanilla. I run the following in onCreate():

String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
AESObfuscator ob = new AESObfuscator(SALT, getPackageName(), deviceId);
LicenseChecker checker = new LicenseChecker(this,
    new ServerManagedPolicy(this, ob), BASE64_PUBLIC_KEY);
checker.checkAccess(this);

Did something change in the licensing code after API 8? Has anyone else been able to test licensing in anything other than API 8?

Update: The same problem happens with the Market Licensing Sample app that Google supplies.

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

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

发布评论

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

评论(1

梦过后 2024-10-24 12:48:45

无法绑定到服务通常意味着您尚未在清单中声明该服务。

阅读此处

您的第二个错误:

  Activity com.zigzagworld.tehillim.Tehillim has leaked ServiceConnection com.android.vending.licensing.LicenseChecker@4051ba58 that was originally bound here

意味着你的服务正在泄漏,当活动完成时你会拆除它吗?

@Override
protected void onDestroy() {
    super.onDestroy();
    checker.onDestroy();
    ...
}

参考:清理 API

Couldn't bind to service usually means you haven't declared that service in your Manifest.

Read up here

Your secondary error:

  Activity com.zigzagworld.tehillim.Tehillim has leaked ServiceConnection com.android.vending.licensing.LicenseChecker@4051ba58 that was originally bound here

Means your service is leaking, do you tear it down when the Activity finished?

@Override
protected void onDestroy() {
    super.onDestroy();
    checker.onDestroy();
    ...
}

Ref: cleanup api

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