I am just starting to use Android Studio for a week and it works great for me, but when I started Android Studio today, I get the error message: "error: duplicate class: mypackage.R". I saw this error before when I used Eclipse, so I tried several times to rebuild the project and restart Android Studio, this did not help.
After reading some Stackoverflow questions, I tried to uninstall R.java and restore again, now I am not getting any recovery errors. The only problem is that Android Studio cannot resolve R, so every line using R gets an error (collecting and starting the project).
I also tried deleting all R.class files, but that does not help either. I checked if any android.R class imports, but they all do not, they just import 'mypackage.R'. I even deleted all my files and checked an older version of my project, but I still have the same problem.
Edit:
If I do not delete R.java, the compiler does not give any error. Just when I try to build, I get a lot of errors, such as: "error: cannot find the symbol variable button_login". If I search for the R.java file for 'button_login', I just find it. I did this with a few mistakes.
Edit2:
When I deleted all the libraries that are now building the project. But the problem is that I need these libraries (HTTPComponents). I added them from maven (File -> Project Structure -> Libaries -> + -sign ') and added them to my .graddle settings:
buildscript { repositories { maven { url 'http://repo1.maven.org/maven2' } } dependencies { classpath 'com.android.tools.build:gradle:0.4' } } apply plugin: 'android' dependencies { compile files('libs/android-support-v4.jar') compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.2.5' compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.2.5' //compile 'org.apache.httpcomponents-httpclient:4.2.5' doesn't work either //compile 'org.apache.httpcomponents-httpmime:4.2.5' doesn't work either } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 15 targetSdkVersion 16 } }
When I run gradlew.bat --stacktrace --info assemble , I get errors that Gradle cannot find libraries from the maven repository. I checked the repository, but they are available. http://search.maven.org/#browse%7C1628757896
android android-studio r.java-file android-resources
ObAt Jun 14 '13 at 8:15 2013-06-14 08:15
source share