Android项目The type R is already defined
现象:
使用Android Studio打开且编译过的项目,再次在Ubuntu源码编译服务器中编译时,报错如下:
ERROR: /home/user/androidSource/out/target/common/obj/APPS/xxxx_intermediates/src/com/xx/xxx/R.java:10:
The type R is already defined
ERROR: /home/user/xxxx/vendor/customer/xxx/xxxx/gen/com/xx/xxx/IMyAidlInterface.java:8:
The type IMyAidlInterface is already defined
ninja: build stopped: subcommand failed.
build/core/ninja.mk:148: recipe for target ‘ninja_wrapper’ failed
make: * [ninja_wrapper] Error 1
make: Leaving directory ‘/home/user/androidSource’
原因:
Android Studio编译后生成的build路径下,R文件、aidl文件与编译服务器中的R文件、aidl文件重复
解决方案:
将Android Studio生成的 build/generated/source/aidl/debug/com.xx.xxx/IMyAidlInterface.java 和 build/generated/source/r/debug/com.xx.xxx/R.java 都删除,然后重新再在Ubuntu源码编译服务器中编译代码