I am currently migrating an Eclipse app to Android Studio. This app was using the in app billing.
My main problem is to compile the project and the aidl file (I guess you all use this file)
I get this error message:
Gradle: error: cannot find symbol class IInAppBillingService
Gradle: error: package IInAppBillingService does not exist
So, following some tutorials, I move this file from com.mypackage.billing to src/main/aidl (see this reference)
But as soon, as I do that, I get this message:
Gradle: Execution failed for task ':xxxxxxxxxxx:compileDebugAidl'.
Failed to run command: (...) C:\Users\xxxx\AndroidStudioProjects\xxxxxxProject\xxxxxxx\src\main\aidl\IInAppBillingService.aidl:45 interface IInAppBillingService should be declared in a file called com\xxxxxxxx\billing\IInAppBillingService.aidl.
The message is clearly a contradiction with the post from the Google bug page I linked above.
Anyone suceeded to make this aidl file to work and can help me?
Just to inform, some links I followed:
I know it sounds so easy, but I copy paste from google sample all folder
https://github.com/googlesamples/android-play-billing/tree/master/TrivialDrive/app/src/main
and next I clean and rebuild project and it found a reference.
src/main
calledaidl
aidl
, selectnew->add package
Enter Name of the package
com.android.vending.billing
Copy
IInAppBillingService.aidl
from the directoryAndroid/Sdk/extras/google/play_billing
to the directoryApp_name/app/src/main/aidl/com/android/vending/billing
can not resolve symbol IInAppBillingXXXXXX
Build
from android studio menu , click onRebuild Project
. This will generateIInAppBillingService.java
file insideApp_Name/app/build/generated/source/aidl/debug/com/android/vending/billing
. This will solve the issue.I've tried every solutions, but the problem was that Android Studio had compiled, with any apparent reason, in a different build type of the module that contains the AIDL packages than it was specified by the settings. From debug to release, so the other modules couldn't see the AIDL pkg. Switching from debug to release and turns back, solved my problem.
We need to add
create folder - src/main/aidl/packagename and place aidl file under this.
In the aidl file - mention the package name. package packagename
Now clean the project, rebuild the project - We can the corresponding java file for the aidl generated in app\build\generated\source\aidl\debug\packagename\youraidl.java
Adding this as an answer since it seemed to help quite a few people.
Note: Make sure you include the necessary import if your reference isn't working
https://issuetracker.google.com/issues/36973270
Edit From Comment
After I did this, the references to IInAppBillingService in my code were still highlighted as errors, but after rebuilding the app, the class was recognized
The rest of posts here didn't work for me till I created a new folder like shown here.