How to Add the Aidl File to Android Studio (From the In-App Billing Example)

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

Just as the error message says, you need to put IInAppBillingService.aidl in the correct directory dictated by it's package (com.android.vending.billing).

Within the src/main/aidl/ folder you already have, put the .aidl file in com/android/vending/billing/.

Android Studio: How to import AIDL file from a different Android Studio project?

Problem "worked around". Here is how:

  1. I undid the manual addition into the app's build.gradle:

sourceSets {
main.java.srcDirs += '../../NoActivity/app/src/main/aidl/com/example/tutorialspoint7/noactivity'
}


  1. I manually created the folder ..\AIDLActivity\app\src\main\aidl\com\example\tutorialspoint7\noactivity, and then copied over to there the original IMyAidlInterface.aidl file from the 'NoActivity' service project.

  2. Adding import com.example.tutorialspoint7.noactivity; in AIDLActivity.java doesn't work!!! so... I worked around this by simply referencing IMyAidlInterface using its fully qualified name:

Sample Image


  1. Gradle sync the projects

  2. The AIDLActivity project now builds without any errors. :-)

Credits goes to this Jun 18, 2013 post by dominik2...@gmail.com: https://code.google.com/p/android/issues/detail?id=56755#c1


Update: I managed to avoid the explicit fully qualified name ugliness by simply importing the specific interface, not the package (duh!):

Sample Image

All is well now but... Why do I have to keep copying the interface file whenever it changes in the original service, instead of just referencing it? I wish there were a way to reference (instead of copy) an AIDL file in Android Studio (version 2.2.3).

create directory for aidl file

Use your default system file explorer. Navigate to the src/main folder of your project and create the following folders.

  • create folder aidl
  • inside the aidl folder: create folder com
  • inside the aidl/com folder: create folder android
  • inside the aidl/com/android folder: create folder vending
  • inside the aidl/com/android/vending folder: create folder billing

Then paste the IInAppBillingService.aidl file inside your billing folder. Back to Android Studio and you will use the package with the file using the "Android" view.

Android studio can`t find aidl import

In my case, recreating the parcelable AIDL files solved the problem. Delete and recreate e.g. SipProfile.aidl (the content seems to be already correct) containing:

package com.csipsimple.api;
parcelable SipProfile;

I used right click on the aidl folder -> New -> AIDL -> New Aidl File. The root cause could be an internal gradle problem...

Perhaps combining this with a Android Studio restart or Build -> Clean project might also help.

android inapp billing error IInAppBillingService.aidl

You should not copy the IInAppBillingService.aidl in your own directory(aidl\IInAppBillingService.aidl). It should be there in this directory only.

com\android\vending\billing\IInAppBillingService.aidl


Related Topics



Leave a reply



Submit