IntelliJ IDEA 12 duplicate of class R.java and BuildConfig.java

I am using Eclipse for android development and trying to use IntelliJ. I successfully run the application once. But now I could not rebuild the Hello World sample application. What am I missing here? R.java no longer rebuilds. Here is a screenshot of the errors.

enter image description here

And here is my setup

enter image description here

+6
source share
4 answers

This happened to me because I improperly interrupted the source folders. In the project settings, as soon as you click on a specific module, just check if you have any additional folders as source folders. Check out the screenshot. By default, it should be something like below. All marks as buttons should be unchecked.

enter image description here

By mistake, I checked Mark as: "Source" and I got this error. Just take it off.

+25
source

R and BuildConfig are automatically generated by the android build system. Perhaps you somehow copied the auto-generated version of your eclipse project into an idea project, and then created the ideas that were created in the second. By default, the idea would be to use the gen folder for these files, which is marked as the source folder. Make sure there are no other source folders containing these files.

You can quickly find classes by pressing Ctrl + N and starting to enter the class name. If you find duplicate results, delete them and let the idea restore the correct results.

+1
source

Unfortunately, you may not like my answer, but my project should take place yesterday, and I do not have time to check all the settings to fix the problem.

As I decided, this is to recreate a new project only by copying src, res, lib, etc. This was very difficult and presented other problems (manifest files and launch / debug configurations), but it turned out to be relatively short rather than creating a new ANYWAY project and sifting through build options, which may or may not be valid.

I encountered a problem while trying to add KSOAP2 libraries to the IDEA project, and although KSOAP has nothing to do with this problem, I may have imported them incorrectly for the first time and created additional self-relational dependencies. It makes sense, but trying to figure out how to cancel it would be almost impossible.

0
source

you can try deleting r and buildconfig files from com / x / x folder in android -> java

which fixed this for me.

0
source

Source: https://habr.com/ru/post/955284/


All Articles