how to compile aidl file in android project?

早过忘川 提交于 2021-02-20 13:53:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!