While building Android source code I am getting this error:
out/target/common/obj/APPS/SystemUI_intermediates/src/com/android/systemui/R.java:10: duplicate class: com.android.systemui.R
Even if I execute the rm
command to remove that file or execute make clean
. Why is that, and how do I deal with it?
You probably have 2 R.java files in 2 different directories. You should run a search to locate and delete both of them, then try to rebuild.
One build system can leave generated R.java
source file in one directory, while other build system will take it as a regular source file and put generated R.java into another directory.
For example, you can use AOSP building process, but after opening your sources in IntelliJ it breaks, because IntelliJ has put extra R.java under gen/
directory.
Summary: properly clean your output directory and check that your source directories doesn't get extra R.java file. run find . -name R.java
in project root directory to see if any reduntant R.java files like in gen
dir
It did not help me deleting the duplicated R.java and BuildConfig files because it was always recreating it and showing the above error.
What helped me is understanding why the files where duplicated at the first places. In my case it was because I mistakenly made a loop dependency between my modules in the project. This way when compiler started creating classes for one of the modules it already compiled as a dependency it showed the error. Removing the unneeded dependency and recompiling the project fixed the problem.
P.S.
The reason I did not find the dependency problem right away is because the Android studio I am currently using (0.6.1) has a bug where sometimes the project settings view gets buggy and shows modules that were already removed or does not show modules that are currently there in the dependency list. Restarting the Android studio fixes the problem, so I suggest restarting before applying the above fix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With