11

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.

Xazen
  • 822
  • 2
  • 12
  • 26
  • possible duplicate of [how can I add the aidl file to Android studio (from the in-app billing example)](http://stackoverflow.com/questions/17836234/how-can-i-add-the-aidl-file-to-android-studio-from-the-in-app-billing-example) – Kalel Wade May 12 '15 at 18:28

12 Answers12

28

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!

NateS
  • 5,751
  • 4
  • 49
  • 59
  • 2
    Wow. You probably saved me a week or something. I would never have found that out! Thanks :D – l33t Jul 22 '13 at 18:49
  • 1
    This is the funniest answer I believed it... and it worked... TIP 4 OTHERS : this is not a joke... It really works. dun ignore as joke. – jeet.chanchawat Sep 27 '13 at 17:30
  • 2
    @yehudahs, the Android devs just don't spend the time to make their tools solid. Good enough and move on. – NateS Jan 03 '14 at 20:02
  • 1
    Worked for me. Very quick solution! – Rino Nov 17 '14 at 11:59
  • 1
    For the benefit of folks like me: "unchecking all the builders on the project properties" means on Eclipse (left pane): Right-click the project that exhibits this issue > Select `Properties` > Select `Builders` (left pane, 4th item from top, below 'Android Lint Preferences') > Right-pane, list of 4 checkboxes to uncheck (then check): Android Resource Manager, Android Pre Compiler, Java Builder, Android Package Builder. – WebViewer Oct 06 '22 at 07:52
6

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.

Rev Tyler
  • 601
  • 7
  • 17
  • Commenting out everything so it builds still didn't cause my AIDL file to get compiled. – NateS Nov 23 '11 at 23:39
  • 1
    Is it in the right place? The .AIDL file must be under src/com/android/vending/billing/ to build properly. – Rev Tyler Nov 24 '11 at 03:41
  • Yep, it just doesn't build. A coworker has the same problem, yet another and the build server has it compile just fine. WTH?! – NateS Dec 05 '11 at 01:54
  • What really solved this problem for me is switching the workspace on Eclipse from `\\myhost\workspace` to `M:\workspace`. Turns out that on Windows, aidl.exe will crash (producing a .dmp CrashDump) if using network share UNC (e.g. \\host\workspace) instead of mapped drive (e.g. H:\workspace). I only discovered this after I got verbose debug log of the build: `Window > Preferences > Android > Build` (Build output: Verbose), then `Window > Show View > Console`, then in the Console tab, click the 'Display Selected Console` icon, to switch from DDMS to Android. – WebViewer Nov 22 '22 at 21:23
2

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.

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
2

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

Community
  • 1
  • 1
2

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.

1

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.

Radu
  • 2,076
  • 2
  • 20
  • 40
1

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

Ketan Parmar
  • 2,962
  • 19
  • 27
  • Thanks, I was searching for a very simple code for in-app purchases pretty long. But it still doesn't solve my problem. I found out that the gen folder doesn't contain IMarketBillingService.java . The com.android.vending.billing doesn't exist either in the gen folder. – Xazen Jun 22 '11 at 11:15
  • I think you have some problem in environment, Is downloaded example works ? – Ketan Parmar Jun 22 '11 at 12:01
  • Yes it works. Just as my old project, where I am using the same code. The 3 projects (including yous) are in the same workspace. I try to copy the IMarketBillingService.java from the gen folder of the old project to com.android.vending.billing of the new project. That way it works! But I wonder why my new project won't generate this java-file. – Xazen Jun 22 '11 at 13:12
  • That URL leads to nowhere now (2022-11-21). – WebViewer Nov 21 '22 at 21:05
1

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

Xazen
  • 822
  • 2
  • 12
  • 26
0

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

Gavin Thornton
  • 1,897
  • 1
  • 12
  • 11
0

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.

samwize
  • 25,675
  • 15
  • 141
  • 186
0

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.

Shumoapp
  • 1,489
  • 16
  • 15
-1

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

Jereld
  • 162
  • 7