AIDL 编译报couldn't find import for class原因探究
来源:互联网 发布:excel一列数据分成多列 编辑:程序博客网 时间:2024/05/01 23:30
有如下AIDL代码:
package android.hardware;
import android.content.Context;
/**
* {@hide}
*/
interface IEinkctlService
{
boolean updateModeLock(boolean acquired, Context context);
int retrieveWorkMode();
boolean switchWorkMode(int mode);
}
编译时总是提示couldn't find import for class android.content.Context
似乎是找不到Context类,而实际上我们都知道android.content.Context确实是存在的。
上网搜寻一番,发现遇到此问题的人不少。
其实,要明白这个问题需要先搞清楚什么样的类是需要且可以import进AIDL中的。
参考《Android/OPhone开发完全讲义》第8章里的一段叙述:
“AIDL服务只支持有限的数据类型,因此,如果用AIDL服务传递一些复杂的数据就需要做更一步处理。AIDL服务支持的数据类型如下:
Java的简单类型(int、char、boolean等)。不需要导入(import)。
String和CharSequence。不需要导入(import)。
List和Map。但要注意,List和Map对象的元素类型必须是AIDL服务支持的数据类型。不需要导入(import)。
AIDL自动生成的接口。需要导入(import)。
实现android.os.Parcelable接口的类。需要导入(import)。
其中后两种数据类型需要使用import进行导入,将在本章的后面详细介绍。
传递不需要import的数据类型的值的方式相同。传递一个需要import的数据类型的值(例如,实现android.os.Parcelable接口的类)的步骤略显复杂。除了要建立一个实现android.os.Parcelable接口的类外,还需要为这个类单独建立一个aidl文件,并使用parcelable关键字进行定义。”
到此应该很清楚了,Context类并不是一个实现了Parcelable接口的类,也没有对应的AIDL文件,因此不能够在AIDL中import。
补充一句,网上有一种“办法”,说是在frameworks/base/Android.mk中的LOCAL_AIDL_INCLUDES := $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)前加上LOCAL_AIDL_INCLUDES := 欲import的类所在位置。其实这种“办法”也是受上面所说的import规则限制的。一个没有实现Parcelable接口的类,这种“办法”也是无能为力的。
- AIDL 编译报couldn't find import for class原因探究
- AIDL 编译报couldn't find import for class原因探究
- AIDL 编译报couldn't find import for class原因探究 .
- AIDL 编译报couldn't find import for class原因探究
- AIDL 编译报couldn't find import for class原因探究
- 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
- Android aidl 编译错误:couldn't find import for class
- 在Eclipse编译aidl文件中出现couldn't find import for class原因
- 在Eclipse编译aidl文件中出现couldn't find import for class原因
- 在Eclipse编译aidl文件中出现couldn't find import for class原因
- 在Eclipse编译aidl文件中出现couldn't find import for class原因
- Android AIDL编译报couldn't find import for class android.content.Intent
- Android中AIDL 编译报couldn't find import for class解决办法
- Eclipse编译AIDL报错couldn't find import for class
- AIDL couldn't find import for class
- 设计模式 - Provider Pattern(提供者模式)
- getaddrinfo (翻译 man 3) --未完
- dhcp 安装记
- 俺的虚拟机能上网了,可把俺高兴坏了
- 2010年大规模技术架构的思路
- AIDL 编译报couldn't find import for class原因探究
- google ProtoBuf开发者指南(比xml和jason都好的协议)
- 数据挖掘研究&开发网站汇总
- Android应用Eclipse开发环境搭建
- Oracle 10g常见问题精选
- 游戏效率优化 之 如何降低容器子集好庞大时鼠标的滑动消耗
- Fuction相关知识
- dede中安装帝国备份出现错误
- poj 3259