Can't build IMarketBillingService.aidl for inApp purchase
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 g开发者_开发百科ot 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.
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!
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.
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.
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.
I had this problem, here is what saved me:
- Create a new directory named 'aidl' under 'src/main/'. It should look like 'src/main/aidl'.
- Add a new package name 'com.android.vending.billing' to the directory 'src/main/aidl'
- Copy 'IInAppBillingService.aidl' into the package created above. In the end, it should look similar to the image below.
References
https://code.google.com/p/android/issues/detail?id=56755 https://stackoverflow.com/a/22769862/2615737
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
At the end I uses a generated java file of a older project instead of the IMarketBillingService.aidl. Now it works.
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.
Import the whole "android-sdk-macosx/extras/google" folder and all its projects. The "com.example.dungeons.Dungeons" project should compile ok now.
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
.
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.
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
精彩评论