Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

how can I add the aidl file to Android studio (from the in-app billing example)

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:UsersxxxxAndroidStudioProjectsxxxxxxProjectxxxxxxxsrcmainaidlIInAppBillingService.aidl:45 interface IInAppBillingService should be declared in a file called comxxxxxxxxillingIInAppBillingService.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?

enter image description here

Just to inform, some links I followed:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Adding this as an answer since it seemed to help quite a few people.

  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. Locate your sdk location and go to "sdkextrasgoogleplay_billing". Default location for the sdk is "C:Program Files (x86)Androidandroid-sdk". If you custom changed it, then you will have to figure out the location through the sdk manager.
  4. Copy 'IInAppBillingService.aidl' into the package created above. In the end, it should look similar to the image below.

Screenshot of result

  1. Rebuild project and it should be good to go.

Note: Make sure you include the necessary import if your reference isn't working

import com.android.vending.billing.IInAppBillingService;

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...