Android Studio: disabling “External build” to display error output create duplicate class errors

后端 未结 5 1358
天涯浪人
天涯浪人 2021-01-12 00:23

I am starting my migration from Eclipse to Android Studio, and start playing with new projects on Studio.

My test project was working fine till I got some errors mes

相关标签:
5条回答
  • 2021-01-12 00:52

    Ok, I also have the same problem, and this is what worked for me. I first unticked external build from compiler settings. Then when I compiled i get two errors related to R.java, duplicate class. Then i delete the build folder manually from finder. Then rebuild it from android studio, but still same error. Then I again go back to compiler preference and tick the external build setting, and it worked fine after that. Looks like some bug.

    0 讨论(0)
  • 2021-01-12 00:54

    apparently, or at least for me 0.1.5 has a bug and cannot run in external build because of some path error you can read about here https://code.google.com/p/android/issues/detail?id=56628

    so i switched to internal building, and then i hit the double R symbol bug

    after deleting the build path application is compiled without errors but the build folder is not fully rebuilt, I'm missing the R.java file which the internal builder does not make.

    i've rebuilt it on the external builder on an unupdated version as a temp workaround while this issues is fixed.

    btw if anyone knows how to tell internal gradle to rebuild the build folder please share.

    0 讨论(0)
  • 2021-01-12 01:08

    I just had the same problem and found a way to solve it (You can do this with Android Studio open):

    • Go to you Android Studio projects folder located in c:\users[USERNAME]\AndroidStudioProjects
    • Locate your project folder and open it.
    • Delete the folder named build.
    • From here, enter your application name folder, where you can find another build folder among with libs and src folders and a file named build.gradle.
    • RENAME the build folder to build2 or something else.
    • Now in Android Studio go to Build->Rebuild Project.
    • And after the project was rebuilt, open again the folder where the build2 folder that you renamed is located.
    • Delete the new folder named build that was created.
    • Rename your build2 folder to build again.

    Done.

    0 讨论(0)
  • 2021-01-12 01:09

    So, just to let you know...

    A few minutes after I posted my question, Google released an update to Android Studio (0.1.5) See link: https://plus.google.com/+AndroidDevelopers/posts/Y9vhvGaHCbh

    Tor Norbye kindly answered my question in this community, and I am sharing here

    So the workaround I quoted in the OP is no more mandatory.

    Enabling again External build after upgrading Android Sudio let me see the real errors ( a library and some Gradle import that I fixed)

    So, I consider the Android Studio upgrade as the best answer to this question...

    0 讨论(0)
  • 2021-01-12 01:16

    I've found a question like this that has some replies here:

    Cannot resolve R.java, duplicate class

    You can try this:

    • Delete the Build folder generated by Android Studio automatically

    Also you can try to Rebuild project by clicking Build->Rebuild project after deleting build folder.

    0 讨论(0)
提交回复
热议问题