(新)Android中framework层下添加aidl编译说程序包不存在

因为特殊要求,我在framework层下添加了一个aidl文件IBluetoothShp.aidl文件,但是在编译时却说程序包不存在,错误如下

[java] view plain copy
  1. frameworks/base/core/java/android/bluetooth/BluetoothShp.java:227: 错误: 找不到符号  
  2.     private IBluetoothShp mService;  
  3.             ^  
  4.   符号:   类 IBluetoothShp  
  5.   位置: 类 BluetoothShp  
  6. frameworks/base/core/java/android/bluetooth/BluetoothShp.java:281: 错误: 找不到符号  
  7.         Intent intent = new Intent(IBluetoothShp.class.getName());  
  8.                                    ^  
  9.   符号:   类 IBluetoothShp  
  10.   位置: 类 BluetoothShp  
  11. frameworks/base/core/java/android/bluetooth/BluetoothShp.java:895: 错误: 程序包IBluetoothShp不存在  
  12.             mService = IBluetoothShp.Stub.asInterface(service);  
  13.                                     ^  
  14. 注: 某些输入文件使用或覆盖了已过时的 API。  
  15. 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。  
  16. 注: 某些输入文件使用了未经检查或不安全的操作。  
  17. 注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。  
  18. 3 个错误  
  19. make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar] 错误 41  
  20.   
  21. #### make failed to build some targets (01:25 (mm:ss)) ####  

可是framework目录下明明存在该文件啊

(新)编译Android系统AIDL模块出现couldn't find import for class错误的解决办法


纠结了好久终于找到了该问题,在此记录一下,在framework层下的.mk文件中将你新添加的aidl添加进去,像我这个错误,我是在framework/base/../../,下添加的aidl,找到base下的Android.mk文件,然后添加以下一段话


[java] view plain copy
  1. core/java/android/bluetooth/IBluetoothShp.aidl \  

.mk文件下某段代码如下:

(新)编译Android系统AIDL模块出现couldn't find import for class错误的解决办法


列出直接传递给编译器的源代码文件


可以在该文件中看到:

[java] view plain copy
  1. ## READ ME: ########################################################  
  2. ##  
  3. ## When updating this list of aidl files, consider if that aidl is  
  4. ## part of the SDK API.  If it is, also add it to the list below that  
  5. ## is preprocessed and distributed with the SDK.  This list should  
  6. ## not contain any aidl files for parcelables, but the one below should  
  7. ## if you intend for 3rd parties to be able to send those objects  
  8. ## across process boundaries.  
  9. ###guoyongcan merge from nxp patch 20160428 line:200  
  10. ## READ ME: ########################################################  
  11. LOCAL_SRC_FILES += \  
  12.     core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl \  

每当往sdk中添加aidl文件时,要将其添加到如下列表,这个列表不包含任何打包的aidl文件,如果你希望第三方可以跨进程通信发送对象可以添加进去



以上信息引用博主 zrf1335348191 的;

重点来了:

我也遇到编译aidl一直错的问题,楼上所用的方法也试过,还是不行,后面直接把aidl文件换个目录,再改下包名和其它文件的引用包名,编译通过,

问题来了:为什么有的包下加的aidl不能编译通过。。。(frameworks/base/core/java/android/app)


版权声明:本文为博主原创文章,未经博主允许不得转载

因为特殊要求,我在framework层下添加了一个aidl文件IBluetoothShp.aidl文件,但是在编译时却说程序包不存在,错误如下

[java] view plain copy
  1. frameworks/base/core/java/android/bluetooth/BluetoothShp.java:227: 错误: 找不到符号  
  2.     private IBluetoothShp mService;  
  3.             ^  
  4.   符号:   类 IBluetoothShp  
  5.   位置: 类 BluetoothShp  
  6. frameworks/base/core/java/android/bluetooth/BluetoothShp.java:281: 错误: 找不到符号  
  7.         Intent intent = new Intent(IBluetoothShp.class.getName());  
  8.                                    ^  
  9.   符号:   类 IBluetoothShp  
  10.   位置: 类 BluetoothShp  
  11. frameworks/base/core/java/android/bluetooth/BluetoothShp.java:895: 错误: 程序包IBluetoothShp不存在  
  12.             mService = IBluetoothShp.Stub.asInterface(service);  
  13.                                     ^  
  14. 注: 某些输入文件使用或覆盖了已过时的 API。  
  15. 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。  
  16. 注: 某些输入文件使用了未经检查或不安全的操作。  
  17. 注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。  
  18. 3 个错误  
  19. make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar] 错误 41  
  20.   
  21. #### make failed to build some targets (01:25 (mm:ss)) ####  

可是framework目录下明明存在该文件啊

(新)编译Android系统AIDL模块出现couldn't find import for class错误的解决办法


纠结了好久终于找到了该问题,在此记录一下,在framework层下的.mk文件中将你新添加的aidl添加进去,像我这个错误,我是在framework/base/../../,下添加的aidl,找到base下的Android.mk文件,然后添加以下一段话


[java] view plain copy
  1. core/java/android/bluetooth/IBluetoothShp.aidl \  

.mk文件下某段代码如下:

(新)编译Android系统AIDL模块出现couldn't find import for class错误的解决办法


列出直接传递给编译器的源代码文件


可以在该文件中看到:

[java] view plain copy
  1. ## READ ME: ########################################################  
  2. ##  
  3. ## When updating this list of aidl files, consider if that aidl is  
  4. ## part of the SDK API.  If it is, also add it to the list below that  
  5. ## is preprocessed and distributed with the SDK.  This list should  
  6. ## not contain any aidl files for parcelables, but the one below should  
  7. ## if you intend for 3rd parties to be able to send those objects  
  8. ## across process boundaries.  
  9. ###guoyongcan merge from nxp patch 20160428 line:200  
  10. ## READ ME: ########################################################  
  11. LOCAL_SRC_FILES += \  
  12.     core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl \  

每当往sdk中添加aidl文件时,要将其添加到如下列表,这个列表不包含任何打包的aidl文件,如果你希望第三方可以跨进程通信发送对象可以添加进去

相关文章: