1

In every project, there is a gradle error with R. R is red and build is failed. I haven't used any images in my project.

error is like this:

My gradle is:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
Vladimir Jovanović
  • 2,123
  • 2
  • 20
  • 39
Aishwarya
  • 19
  • 1
  • 1
  • 3
  • Possible duplicate of [R cannot be resolved - Android error](http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error) – Al Lelopath Feb 09 '17 at 18:51
  • Have you made any changes to your application's package name recently? Sometimes, this can cause a problem if your R file has a different package name than your java file. – Epicality Feb 09 '17 at 18:52
  • No, I haven't made any changes in my pkg name – Aishwarya Feb 09 '17 at 19:01

4 Answers4

0

Either you might be having some issues with any of the xml files or you may import 'R' with your applications package name if you have resources.

0

Add below lines in your build.gradle file:

dexOptions {
    javaMaxHeapSize "4g"
}

Android Studio Google JAR file causing GC overhead limit exceeded error

Community
  • 1
  • 1
Ashish Kudale
  • 1,132
  • 1
  • 22
  • 45
  • after adding this it is saying: Error:(25, 1) A problem occurred evaluating root project 'Addition'. > Could not find method dexOptions() for arguments [build_3x5agyw9liwk00axdmp8pbnxs$_run_closure3@3b16563f] on root project 'Addition' of type org.gradle.api.Project. – Aishwarya Feb 09 '17 at 19:06
0

Simply clean/rebuild the project and invalidate caches restart

0

I think gradle is not importing all the packages remove the gradle and add new one with same version.

Anmol Nijhawan
  • 825
  • 1
  • 7
  • 14