I am trying to get the google In App Billing services to work.
I've got so far that the service is bound and connected, but once I try to fetch some data from the service it crashes with the log:
04-02 10:36:32.795 10569-10651/my.app.package E/IAP﹕ java.lang.SecurityException: Binder invocation to an incorrect interface
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at billing.IInAppBillingService$Stub$Proxy.getSkuDetails(IInAppBillingService.java:251)
at my.app.package.libs.clientbackend.iap.IAPHelper$FetchItemsCallable.call(IAPHelper.java:102)
at my.app.package.libs.clientbackend.iap.IAPHelper$FetchItemsCallable.call(IAPHelper.java:89)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
This is my code so far:
The activity that shows the Purchases:
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, this, Context.BIND_AUTO_CREATE);
The IAB calls once the service has connected:
Bundle itemBundle = new Bundle();
itemBundle.putStringArrayList("ITEM_ID_LIST", new ArrayList<>(Arrays.asList(itemIds)));
Bundle detailsBundle = service
.getSkuDetails(3, context.getPackageName(), "inapp", itemBundle);
It fails on the last line ...getSkuDetails(...
with the error posted above.
I did some research on this matter and found our that it might be caused by wrong package names. I've included the IInAppBillingService.aidl
like it's described on google's documentation but I am still getting a wrong package on import:
The file is at: src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl
But when I am importing the generated class Android Studio uses this import path:
import billing.IInAppBillingService;
According to the documentation this should actually be:
import com.android.vending.billing.IInAppBillingService;
Is there still something wrong with my project setup or does anyone know the cause of this error?
Much thanks in advance, McFarlane
I had the same problem and I figured out that aidl file must be in the com.android.vending.billing
package in src folder but you put that in src/main/aidl/com/android/vending/billing
which is not correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With