7

I was coding in android studio then this error will appear:

cannot resolve symbol 'R'

Error:Execution failed for task ':demo:processDebugResources'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Android Development\sdk\android-sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1

this is my Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "br.liveo.ndrawer"
        minSdkVersion 21
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile project(':library')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
}

I use Android Studio V 1.0 , all API 22 and API 21 and Tools and Extras of SDK Manager are updated.

this options not working:

File/ Invalidate Cashes/Restart

Build/ Rebuild Project

Build/ Clean Project

what should I do know?

tnx

Salar Rastari
  • 2,280
  • 5
  • 22
  • 35

11 Answers11

10

I solve my problem:

1) check all your XML files for given unknown src. ImageView or ImageButton or any think, et:

android:src="@drawable/cards"

then

Build/ Rebuild Project

or

Build/ Clean Project

or

File/ Invalidate Cashes/Restart

Your problem will solve for sure 100% :D

Salar Rastari
  • 2,280
  • 5
  • 22
  • 35
8

This error can be raised because of duplicate resources/files. To find out the names and path of duplicate resources:

  1. Go to File > Settings > Build, Execution, Deployment. Select Compiler from sub-options.

  2. Type --debug against Command-line Options. Press Ok.

enter image description here

  1. Run your project. In the Messages Window of AS, compiler will tell you about all problems.

enter image description here

Hope it helps!

NightFury
  • 13,436
  • 6
  • 71
  • 120
2

I found a solucion problem was because I add 2 image one in drawable and other one in drawable-es but in this last the name was (same than drawable for example myimagen.jpg) but the extencion was in uppercase

in drawable this was myimagen.jpg and drawable-es it was myimagen.JPG

I rebuild, clean, and rebuild, re-start android studio, re-start my pc and it did not work, then I thoungh my be the name because my error say "processdebugresources"

Error:Execution failed for task ':app:processDebugResources'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\auc\AppData\Local\Android\sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1

angel
  • 4,474
  • 12
  • 57
  • 89
2

I was compiling with build version 23.0.2 and realized 23.0.3 was available in the Android SDK. Installed the newer version, changed build version in build.gradle, and Android build worked after that.

Should also note that this error didn't start happening until I changed my splash screen images to 9-patch.

orangeable
  • 45
  • 2
  • 8
1

In my case, I had renamed a file in my project's assets folder to "~/blah" in Finder hoping it would place it in my home directory like in Linux, but instead, Finder literally prepended the tilde-slash to my filename. aapt didn't like this.

0

I had the same problem for a while, i just upgraded android studio to v1.3 in the canary channel. That solved it.

Sanket Berde
  • 6,555
  • 4
  • 35
  • 39
0

Update your buildtoolsversion to 23.0.2 in app level gradle fileand add the following to the same gradle:
The defaultconfig() method should be like

 defaultConfig {
        applicationId "zohoshow.suite"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        generatedDensities = []
        multiDexEnabled true
    }

and add the following as another method parallel to defaultconfig

aaptOptions {
        additionalParameters "--no-version-vectors"
    }
bummi
  • 27,123
  • 14
  • 62
  • 101
Jenison Gracious
  • 486
  • 4
  • 13
0

This might have happened if you have initialized something with null instead of @null in xml.

Akash Jp
  • 162
  • 1
  • 10
0

Regarding: cannot resolve symbol 'R'

Reading the answers, it seems like a lot of folks have been resolving this by studying their XML files to find the last thing that they typed that is wrong. But this is unnecessary, the file and line number of the error in the XML can be found.

On the Terminal tab inside Android Studio, type:

gradlew clean
gradlew assmeble

For example, one answer remarked that they accidently did:

android:background="null"

Instead of:

android:background="@null"

I intentionally introduced this error into my XML. After running gradlew assemble. the following feedback is given:

gradlew assemble output

It is reporting that the error happened on line 2 of activity_java.xml and that "null incompatible with attribute..."

Lastly, I would consider upgrading to Android Studio 4.1.1 (or newer) since it has better output on the build tab for resource errors.

Elletlar
  • 3,136
  • 7
  • 32
  • 38
-1

Just Listen To Me...By Searching All The Requirement HINTS About Your May Good Or May Not Be Worked,So Please Goto the Following HINT It will Work For 100% After a Long Search i got this HINT.

Change The buildToolsVersion To compileSdkVersion as Shown Below Code:...

Before: It Was Not Working....

android {
    compileSdkVersion 23
    buildToolsVersion '22.0.1'
    defaultConfig {
        applicationId 'com.kdmsl.kraapp'
        minSdkVersion 14
        versionCode 3
        versionName "1.3"
        aaptOptions {
            additionalParameters "--no-version-vectors"
        }
    }

After Changes:

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.0'
    defaultConfig {
        applicationId 'com.kdmsl.kraapp'
        minSdkVersion 14
        versionCode 3
        versionName "1.3"
        aaptOptions {
            additionalParameters "--no-version-vectors"
        }
    }
Anptk
  • 1,125
  • 2
  • 17
  • 28
-1

This is a horrible error. I lost all confidence in android studio because of this.

What happens is when you are making changes to your xml layouts something internally happens with studio generating files.

So you might want to compile after every change.

I had to back out textviews one at a time to get the build to work.

I looked closely at the differences as I put the textviews back in.

There was no difference.

Android studio just has issues.

dcarl661
  • 177
  • 3
  • 9