I am trying to get Google billing services to work.
I still have that the service is connected and connected, but as soon as I try to extract 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:
Activity showing Shopping:
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 when 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);
In the last line ...getSkuDetails(... it does not work with the error mentioned above.
I did some research on this and found that it could be caused by incorrect package names. I have included IInAppBillingService.aidl as described in the google documentation, but I still get the wrong package when importing:
The file is located at: src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl
But when I import the generated class, Android Studio uses this import path:
import billing.IInAppBillingService;
According to the documentation, this should be:
import com.android.vending.billing.IInAppBillingService;
Is there something wrong with my project setup or does anyone know the reason for this error?
Thanks a lot in advance, MacFarlane