因为特殊要求,我在framework层下添加了一个aidl文件IBluetoothShp.aidl文件,但是在编译时却说程序包不存在,错误如下
frameworks/base/core/java/android/bluetooth/BluetoothShp.java:227: 错误: 找不到符号
private IBluetoothShp mService;
^
符号: 类 IBluetoothShp
位置: 类 BluetoothShp
frameworks/base/core/java/android/bluetooth/BluetoothShp.java:281: 错误: 找不到符号
Intent intent = new Intent(IBluetoothShp.class.getName());
^
符号: 类 IBluetoothShp
位置: 类 BluetoothShp
frameworks/base/core/java/android/bluetooth/BluetoothShp.java:895: 错误: 程序包IBluetoothShp不存在
mService = IBluetoothShp.Stub.asInterface(service);
^
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
3 个错误
make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar] 错误 41
#### make failed to build some targets (01:25 (mm:ss)) ####
可是framework目录下明明存在该文件啊
纠结了好久终于找到了该问题,在此记录一下,在framework层下的.mk文件中将你新添加的aidl添加进去,像我这个错误,我是在framework/base/../../,下添加的aidl,找到base下的Android.mk文件,然后添加以下一段话
core/java/android/bluetooth/IBluetoothShp.aidl \
.mk文件下某段代码如下:
列出直接传递给编译器的源代码文件
可以在该文件中看到:
## READ ME: ########################################################
##
## When updating this list of aidl files, consider if that aidl is
## part of the SDK API. If it is, also add it to the list below that
## is preprocessed and distributed with the SDK. This list should
## not contain any aidl files for parcelables, but the one below should
## if you intend for 3rd parties to be able to send those objects
## across process boundaries.
###guoyongcan merge from nxp patch 20160428 line:200
## READ ME: ########################################################
LOCAL_SRC_FILES += \
core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl \
每当往sdk中添加aidl文件时,要将其添加到如下列表,这个列表不包含任何打包的aidl文件,如果你希望第三方可以跨进程通信发送对象可以添加进去