ant 编译 aidl 报告错误: couldn't find import for class
来源:互联网 发布:易语言七夕表白源码 编辑:程序博客网 时间:2024/05/20 21:58
Aidl的使用帮助如下:
- C:/Documents and Settings/Administrator>aidl
- INPUT required
- usage: aidl OPTIONS INPUT [OUTPUT]
- aidl --preprocess OUTPUT INPUT...
- OPTIONS:
- -I<DIR> search path for import statements.
- -d<FILE> generate dependency file.
- -p<FILE> file created by --preprocess to import.
- -o<FOLDER> base output folder for generated files.
- -b fail when trying to compile a parcelable.
- INPUT:
- An aidl interface file.
- OUTPUT:
- The generated interface files.
- If omitted and the -o option is not used, the input filename is used, with th
- e .aidl extension changed to a .java extension.
- If the -o option is used, the generated files will be placed in the base outp
- ut folder, under their package folder
这些信息太少了,还不能让人明白如何使用。帮助信息首句就是“INPUT required”,其实只有"INPUT"仍是不够的,OPTIONS中“-I”是必选而非可选,否则会提示:
- D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteService.aidl:19: couldn't find import for class com.example.android.apis.app.IRemoteServiceCallback
以SDK自带的ApiDemos为实践对象,该工程存储路径为:"D:/JavaTest/ApiDemos/",有三个aidl文件分别为:
com/example/android/apis/app/IRemoteService.aidl
com/example/android/apis/app/IRemoteServiceCallback.aidl
com/example/android/apis/app/ISecondary.aidl
要生成对应的.java文件命令行如下:
- aidl -ID:/JavaTest/ApiDemos/src D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteService.aidl
对,你没看错,"-I"与"D:/JavaTest/***"之间是没有空格的。XX,看来Google里也有相当混蛋的程序员。
执行此条命令后,生成的.java会与.aidl文件在同一目录下。
如果想指定aidl的生成路径,则可以按照aidl的提示信息使用"-o"选项:
- aidl -ID:/JavaTest/ApiDemos/src -oD:/JavaTest D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteService.aidl
对,你还是没看错,"-o"与"D:/JavaTest/**"中间还是没有空格,再次咒骂设计了aidl工具的那个混蛋。
执行此命令后,则生成的aidl文件存于"D:/JavaTest/"路径下了。
在ApiDemos中,IRemoteService.aidl与IRemoteServiceCallback.aidl是互相依赖的,在编译IRemoteService.aidl时,通过使用"-d"可以将其依赖的相关类输出到自定义的文件中.
- aidl -ID:/JavaTest/ApiDemos/src -oD:/JavaTest -dD:/JavaTest/aidl_dependency.txt D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteService.aidl
生成的aidl_dependenry.txt内容如下:
- : /
- D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteService.aidl /
- D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteServiceCallback.aidl
可选项中"-b"的用法不详,帮助信息中的那句“fail when trying to compile a parcelable.”就感觉少说了些内容,"fail"然后干嘛,XX,第三次咒骂设计了aidl工具的那个混蛋。
帮助信息中还有“aidl --preprocess OUTPUT INPUT...”,作用是根据要编译的.aidl生成预处理文件,但具体预处理有啥用,有知道的告诉我下啊。
仍以ApiDemos为例,生成预处理文件为aidl.preprocess:
- aidl --preprocess D:/JavaTest/aidl.preprocess D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteService.aidl D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteServiceCallback.aidl D:/JavaTest/ApiDemos/src/com/example/android/apis/app/ISecondary.aidl
生成的aidl.preprocess内容如下:
- interface com.example.android.apis.app.IRemoteService;
- interface com.example.android.apis.app.IRemoteServiceCallback;
- interface com.example.android.apis.app.ISecondary;
SDK自带了预处理文件为<sdk_path>/platforms/android-<level>/framework.aidl。
“-p”表示编译aidl时以预处理文件为参去生成.java,命令方法如下:
- aidl -ID:/JavaTest/ApiDemos/src -pE:/SoftSetup/AndroidSDK/android_sdk_r08_windows/platforms/android-3/framework.aidl D:/JavaTest/ApiDemos/src/com/example/android/apis/app/IRemoteService.aidl
而通过查看adt的源码可以发现,adt编译aidl使用的正是系统自带的预处理文件framewrok.aidl。
adt源码处理aidl的文件为:<OpenSourceProjectPath>/sdk/eclipse/plugins /com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal /build/PreCompilerBuilder.java,其中的handleAidl()即为编译aidl的执行方法。
转载请注明出处: http://blog.csdn.net/sodino/archive/2011/05/14/6419498.aspx
- ant 编译 aidl 报告错误: couldn't find import for class
- Android aidl 编译错误:couldn't find import for class
- AIDL 编译报couldn't find import for class 解决方法
- Android aidl 编译报couldn't find import for class
- Android aidl 编译报couldn't find import for class
- AIDL couldn't find import for class
- 编译Android系统AIDL模块出现couldn't find import for class错误的解决办法
- aidl文件中出现couldn't find import for class
- android studio aidl couldn't find import for class
- AIDL 编译报couldn't find import for class原因探究
- 在Eclipse编译aidl文件中出现couldn't find import for class原因
- AIDL 编译报couldn't find import for class原因探究
- AIDL 编译报couldn't find import for class原因探究 .
- 在Eclipse编译aidl文件中出现couldn't find import for class原因
- AIDL 编译报couldn't find import for class原因探究
- 在Eclipse编译aidl文件中出现couldn't find import for class原因
- 在Eclipse编译aidl文件中出现couldn't find import for class原因
- AIDL 编译报couldn't find import for class原因探究
- 有getter setter的属性在Inspector视图中设置值
- session与cookie的区别和联系?
- 数组、结构体、指针2
- 数学之美番外篇:进化论中的概率论
- hdu 3962 Microgene (ac自动机+矩阵优化(好题))
- ant 编译 aidl 报告错误: couldn't find import for class
- js获取html中的table元素里的每一行的行号
- PAT 1009. 说反话
- Android 使用Log4j把日志写入SD卡,动态修改输出文件名称
- 判断是否为闰年
- Guide Practice of Perl
- linux expect的用法
- 向左轮播滑动
- Codeforces Round #295 (Div. 2) A+B+C