您的位置:首页 > 移动开发 > Android开发

Android 之工具aidl

2013-05-10 08:43 260 查看
AIDL服务支持的数据类型如下:

Java的简单类型(int、char、boolean等)。不需要导入(import)。

String和CharSequence。不需要导入(import)。

List和Map。但要注意,List和Map对象的元素类型必须是AIDL服务支持的数据类型。不需要导入(import)。

AIDL自动生成的接口。需要导入(import)。

实现android.os.Parcelable接口的类。需要导入(import)。

aidl OPTIONS INPUT [OUTPUT]

OPTIONS:

-I<DIR> import类的查找路径

-d<FILE> 生成需要import的依赖类列表文件

-p<FILE> 指定需要import的类的预处理文件,可以同时指定系统自带的预处理文件framework.aidl和自定义的预处理文件preprocess.aidl

-o<FOLDER> 指定文件输出的目录

-b fail when trying to compile a parcelable.

在编译aidl文件时经常遇到couldn't find import for class ... 表示需要import相关的类,在sdk中有一个framework.aidl文件是系统自带的预处理文件,对于需要导入Parcelable接口的类,

通过引入framework.aidl文件即可解决couldn't find import for class ...问题,对于其他自定义的类,则需要先生成依赖类的预处理文件,通过以下命令生成:

aidl --preprocess /path/preprocess.aidl 1.aidl 2.aidl ....

比如说在编译3.aidl文件时,提示:

couldn't find import for class 1

couldn't find import for class 2

则使用命令:

aidl --preprocess ./preprocess.aidl 1.aidl 2.aidl

编译3.aidl文件:

aidl -I/path/to/project/src -p/path/to/framework.aidl -p./preprocess.aidl 3.aidl
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: