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

前端之家收集整理的这篇文章主要介绍了Android模拟器问题上的市场许可API前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用许可证检查API的 Android应用程序.我已经使用适用于API级别8,9和10的Google API设置了模拟器AVD.我的应用程序在8级AVD上运行良好但在9级和10级AVD上失败.这是一个典型的logcat序列:
  1. 02-14 17:43:55.815: INFO/LicenseChecker(448): Binding to licensing service.
  2. 02-14 17:43:55.935: WARN/ActivityManager(65): Unable to start service Intent { act=com.android.vending.licensing.ILicensingService }: not found
  3. 02-14 17:43:55.935: ERROR/LicenseChecker(448): Could not bind to service.
  4. 02-14 17:44:00.625: INFO/ActivityManager(65): Displayed com.zigzagworld.tehillim/.Tehillim: +2m1s448ms (total +5m43s546ms)
  5. 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
  6. 02-14 17:44:18.025: INFO/InputReader(65): Device reconfigured: id=0x0,name=qwerty,display size is now 320x480
  7. 02-14 17:44:18.025: WARN/InputReader(65): Touch device did not report support for X or Y axis!
  8. 02-14 17:44:19.005: WARN/InputManagerService(65): Window already focused,ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40945580
  9. 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
  10. 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
  11. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:938)
  12. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:833)
  13. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.ContextImpl.bindService(ContextImpl.java:864)
  14. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
  15. 02-14 17:44:20.805: ERROR/ActivityThread(448): at com.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:143)
  16. 02-14 17:44:20.805: ERROR/ActivityThread(448): at com.zigzagworld.tehillim.Tehillim.onCreate(Tehillim.java:76)
  17. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  18. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
  19. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
  20. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  21. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
  22. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.os.Handler.dispatchMessage(Handler.java:99)
  23. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.os.Looper.loop(Looper.java:123)
  24. 02-14 17:44:20.805: ERROR/ActivityThread(448): at android.app.ActivityThread.main(ActivityThread.java:3647)
  25. 02-14 17:44:20.805: ERROR/ActivityThread(448): at java.lang.reflect.Method.invokeNative(Native Method)
  26. 02-14 17:44:20.805: ERROR/ActivityThread(448): at java.lang.reflect.Method.invoke(Method.java:507)
  27. 02-14 17:44:20.805: ERROR/ActivityThread(448): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  28. 02-14 17:44:20.805: ERROR/ActivityThread(448): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  29. 02-14 17:44:20.805: ERROR/ActivityThread(448): at dalvik.system.NativeStart.main(Native Method)
  30. 02-14 17:44:20.835: WARN/ActivityManager(65): Unbind Failed: could not find connection for android.os.BinderProxy@40774fd0

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

我的代码很香草.我在onCreate()中运行以下命令:

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

API 8之后的许可代码是否发生了变化?有没有其他人能够在API 8以外的任何其他方面测试许可?

更新:Google提供的Market Licensing Sample应用程序也会出现同样的问题.

解决方法

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

Read up here

您的次要错误

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

意味着您的服务正在泄漏,您是否在活动结束后将其拆除?

  1. @Override
  2. protected void onDestroy() {
  3. super.onDestroy();
  4. checker.onDestroy();
  5. ...
  6. }

参考:cleanup api

猜你在找的Android相关文章