0
,我發現了以下異常:谷歌IAB幫手bindService崩潰
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{myapppackage2/myapppackage.ui.MainActivity}: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.android.vending.billing.InAppBillingService.BIND }
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$800(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.android.vending.billing.InAppBillingService.BIND }
at android.app.ContextImpl.validateServiceIntent(ContextImpl.java)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java)
at android.app.ContextImpl.bindService(ContextImpl.java)
at android.content.ContextWrapper.bindService(ContextWrapper.java)
at com.android.vending.billing.util.IabHelper.doBindService(IabHelper.java:277)
at com.android.vending.billing.util.IabHelper.startSetup(IabHelper.java:268)
at myapppackage.feature.FeaturesManager.initBilling(FeaturesManager.java:79)
at myapppackage.ui.MainActivity.onCreate(MainActivity.java:374)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$800(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
我GOOGLE了一下,發現我應該補充serviceIntent.setPackage("com.android.vending");
但問題是,我已經擁有它:
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentServices(serviceIntent, 0);
if (resolveInfos != null && !resolveInfos.isEmpty()) {
// service available to handle that Intent
mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
}
else {
// no service available to handle that Intent
if (listener != null) {
listener.onIabSetupFinished(
new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,
"Billing service unavailable on device."));
}
}
xiaomi mi-4c,android 5.1.1,rooted。
有什麼想法?
這不是解釋,而是步步爲營。任何關於根源的想法? – 4ntoine
答案已更新。 –
請參閱此鏈接的根本原因http://stackoverflow.com/questions/27981246/dealing-with-implicit-intent-future-deprecation-in-lollipop –