问题
Hi can anyone tell me where to place aidl file in project tree and how to use it in project source. Will aidl file gets compiled, If i build apk ?? How to use it in eclipse ?
回答1:
AIDL (Android Interface Definition Language) is similar to other IDLs you might have worked with. It allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC)
Where to place aidl file ?
Save aidl file in the source code (in the src/ directory) of both the application hosting the service and any other application that binds to the service.
Will aidl file gets compiled, If i build apk ?
When you compile your project, then there project automatically generate one file in gen foler.
Look at here for more details.
回答2:
In addition to the previous answers, you can also build just the AIDL files.
Android Studio 3.0.1 (It should be the same in Android Studio 2.x.x):
View -> Tool Windows -> Gradle
Right-click on compileDebugAidl -> Run
回答3:
In case anybody is wondering where to place the AIDL file when using the Gradle build system (since the docs still tell you to place it in src/
):
Under Gradle you have to place the AIDL file in src/main/aidl/
for it to be automatically detected.
During the build the Java interface and stub implementation is then put into build/generated/source/aidl/{debug,release}/, otherwise the information provided by Chirag Raval is still correct.
来源:https://stackoverflow.com/questions/12525546/how-to-compile-aidl-file-in-android-project