If you do Android development, you should know the aidl tool, but do you have any people who use the aidl command line tool, if there is one, you can't write anything for him or her !!!!
If you use the aidl command line, you will certainly encounter errors like this.
$ Aidl iremoteservicecallback. aidl <br/> iremoteservicecallback. aidl: 19: Couldn't find import for class android. Location. Location
When an error occurs, you must first check how aidl helps you write it.
$ Aidl <br/> usage: aidl options input [Output] <br/> aidl -- preprocess output input... <br/> options: <br/>-I <dir> Search Path for import statements. <br/>-D <File> generate dependency file. <br/>-P <File> File Created by -- preprocess to import. <br/>-O <folder> base Output Folder for generated files. <br/>-B fail when trying to compile a parcelable.
What do you think of this concise and unclear introduction?
Writing one more sentence will die !!! I hate this kind of dummy. Do I think Android Developers have a strong understanding? Not only does it help people, but tutorial does. There is only one sentence
Add the. aidl file to your makefile-(the ADT plugin for eclipse manages this for you). Android plugin des the compiler, called aidl, In the tools/directory.
Let's solve this Swine Blood problem step by step.
When the document cannot help you, read the android code. How to get the code is clearly written in Google's documentation. In fact, most of Google's documentation is still clear enough in tat.
BelowANDROIDRepresents the root of the android code tree
ANDROID/frameworks/base/tools/aidlIs the C ++ code of the aidl tool. I didn't get any useful information from it. Maybe it's probably because I have no idea about C ++ code...
Change the hole if the gun is not hit. Since eclipse can process the aidl file, I will go to the android plug-in ADT of Eclipse. This is the file related to aidl.
Android/SDK/Eclipse/plugins/COM. Android. Ide. Eclipse. ADT/src/COM/Android/IDE/Eclipse/ADT/Internal/build/precompilerbuilder. Java
You asked me how to find it? Classic tools on Linux must be used frequently before they can be regarded as classic tools.
$ Grep-ri aidl Android/Android-source/SDK/Eclipse/plugins/COM. Android. Ide. Eclipse. ADT/
There is one in row 880private boolean handleAidlThis is the name of the function. All the way down until 890 rows
Command [index ++] = "-P" + SDK. getcurrent (). gettarget (getproject ()). getpath (// $ NON-NLS-1 $ <br/> iandroidtarget. android_aidl );
You can see that the-p parameter is found here, but you still don't know what it is. Following this code tracing, we found such a file.
Android/SDK/sdkmanager/libs/sdklib/src/COM/Android/sdklib/iandroidtarget. Java
Now we can find 30 rows, and we finally know that the-P originally referredfile created by --preprocess to importIsframework.aidlFile
/** OS path to the "framework. aidl" file. */<br/> Public final static int android_aidl = 2;
Haha, let me verify your real identity !!!
$ Find Android/android-sdk-linux_86/-name framework. aidl <br/> Android/android-sdk-linux_86/platforms/Android-3/framework. aidl Android/android-sdk-linux_86/platforms/Android-4/framework. aidl Android/android-sdk-linux_86/platforms/Android-6/framework. aidl <br/>...
Thisframework.aidlThe file is also very brainless. Although the annotation is not very important, this code has no self-explanatory power at all, and no comments are written to demonstrate its purpose --
At this point, confirm the-p Parameter
The revolution is far from over. To solve the problem of Swine Blood, you need to know how to write the-I parameter.
Continue reading abovePreCompilerBuilder.java896 lines of Files
For (ipath P: sourcefolders) {<br/> ifolder F = wsroot. getfolder (p); <br/> Command [index ++] = "-I" + F. getlocation (). toosstring (); // $ NON-NLS-1 $ <br/>}
I think you can see what this means, that is, the source directory of your project, which is generally the src directory.
At this point, the problem is solved. In the end, the method to use the aidl command line tool is as follows:
$ Aidl-I/path/to/project/src-P/path/to/framework. aidl interface. aidl
Thank you for your country.