Home » Android » android – Can't build IMarketBillingService.aidl for inApp purchase

android – Can't build IMarketBillingService.aidl for inApp purchase

Posted by: admin May 14, 2020 Leave a comment

Questions:

I try to import com.android.vending.billing.IMarketBillingService. But I got the error:

The import com.android.vending.billing.IMarketBillingService cannot be resolved.

I have got another project where I do exactly the same thing and it works perfectly. I copied the files I need for in-app purchase to the new project. That means the data have to be correct. (I replaced the package name) I check multiple times wether I forgot a class. A few days ago I copied the files for a colleague and it works as well.

I tried cleaning and freshing the project as well.

How to&Answers:

I had this same problem as well. I found that putting in the .aidl before any in-app billing sources in to your project it will generate the .java.

When you try to reference that .java file before it’s created your project will contain errors. Because you have errors it won’t build your resources, ie R.java or the IMarketBillingService.java.

Answer:

I fixed this by unchecking all the builders on the project properties, hit OK, then check them all again and hit OK. Thanks a lot, Google!

Answer:

Download Source Code from following link, compare your code with downloaded code, I am sure you will fix your issue.

http://www.anddev.org/resources/file/2875

Answer:

You can also just delete the gen folder in eclipse, this should trigger a rebuild by the eclipse plugin and create the corresponding java class.

Answer:

The following is what solved this problem for me:

The documentation on how to set up in the IInAppBillingService.aidl file is vague:

Copy the IInAppBillingService.aidl file to your Android project.

  • If you are using Eclipse: Import the IInAppBillingService.aidl file into your /src directory.
  • If you are developing in a non-Eclipse environment: Create the following directory
    /src/com/android/vending/billing and copy the IInAppBillingService.aidl file into this directory.

To me, this implied that if I was in Eclipse I should put it in the root of my src directory, but if not then I needed to put it in their specified package. So, I put the IInAppBillingService.aidl in the root of my /src directory and it had all of the failures. That was the problem.

I don’t know why the docs are written like that, but the solution was to put this file into the proper package directory which is com.android.vending.billing as is declared inside the .aidl file. Then it was successfully generated and all of the other files built properly.

Answer:

At the end I uses a generated java file of a older project instead of the IMarketBillingService.aidl. Now it works.

Answer:

In Eclipse at least, what you have to do is change the Java compiler settings(since this is a compiler error).

Try changing the Compiler compliance level from 1.5 to 1.6 or 1.7. It worked for me.

Answer:

I had this problem, here is what saved me:

  1. Create a new directory named ‘aidl’ under ‘src/main/’. It should look like ‘src/main/aidl‘.
  2. Add a new package name ‘com.android.vending.billing‘ to the directory ‘src/main/aidl
  3. Copy ‘IInAppBillingService.aidl’ into the package created above. In the end, it should look similar to the image below.

Screenshot of result


References

https://code.google.com/p/android/issues/detail?id=56755
https://stackoverflow.com/a/22769862/2615737

Answer:

I had this frustrating problem when migrating to a new machine. What worked for me was to build using “ant debug” in the command line to generate the billing services files.

http://developer.android.com/guide/developing/building/building-cmdline.html

Answer:

Import the whole “android-sdk-macosx/extras/google” folder and all its projects. The “com.example.dungeons.Dungeons” project should compile ok now.

Answer:

I tried some of the methods here but didn’t work for me.

What worked out for me is a simple Clean, then Build All.

Answer:

In my case, I had to select Android Project Target from Project Properties>Android>Project Build Target.
Apparently, after my last upgrade of Eclipse, I didn’t download the API level that I used to work on the project. As a result, Eclipse could not resolve the last used API level, and resulted in error.