John81
John81

Reputation: 4074

how to fix 23.0.1\aapt.exe'' finished with non-zero exit value 1

All of a sudden I cannot get Gradle to build any projects under Android Studio.

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

My Gradle is

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.marathon.simplelist"
        minSdkVersion 8
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

Even if I create a new Blank Activity project I still get this error.

I have Android Studio 1.3.1 installed with

SDK Platforms: 5.X, 5.1, 5.0, 4.4, 2.3.3 SDK Tools: SDK Build Tools, SDK Tools 24.4, Platform-Tools 23.0.1

Obviously something is reconfigured locally since even a new empty project will not build. Ideas on how I can resolve this?

Upvotes: 27

Views: 75217

Answers (27)

mohamed murashid
mohamed murashid

Reputation: 719

In my case, i was wrongly mentioned dp as d in dimension file. That cause this issue, once i corrected that value everything working fine. So due to some new added wrong values or files may cause this issue.

Upvotes: 0

Karthik H
Karthik H

Reputation: 1439

I spent nearly 12 hour to find the resolution to this issue and finally I found the resolution.

This kind of supernatural issue, might happen in the below cases,

  1. When your code has some problem, like sometimes IntelliJ/AndroidStudio does not report the compilation errors. Open each class and check for any compilation issues, these compilations issues will be because of not able to resolve few dependencies.

  2. When you have a library that is latest, but you are referring to the oldest version.(Similar to point 1).

  3. When you have a library that is dependent on some other library and that in turn referencing to old library, but your direct library is referring to newer version.

  4. Importing from JFrog Artifactory, but your cache is not cleared, and you app is still holding to older version of .aar file

  5. Your current gradle version of the app is latest, but you imported some other project as library and that version is older.

  6. Your current gradle version of the app is latest, but you imported .aar file from jfrog artifactory and that is build from older gradle version.

when you are trying all the above cases, clean and build, or if this doesn't work, try "invalidate cache and Restart".

error like this will fall in some or the other above mentioned cases.

Happy Coding..!

Upvotes: 0

Soorya
Soorya

Reputation: 189

In my case, due to duplicated attributes in xml causes this issue. For example,

<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:text="Hello" />

Upvotes: 0

Ranjithkumar
Ranjithkumar

Reputation: 18406

You may miss the some resources.

You can find the exact problem using following steps

  1. Click -> gradle (right side)

  2. Goto app-> Tasks -> build -> assembleDebug

  3. Double click assembleDebug

You will get the exact error. you can fix your problem

enter image description here

Upvotes: 3

Avi
Avi

Reputation: 561

In my case, I backtracked everything that I implemented and found that the issue was in the xml layout file that I was using for my login screen.

The relation that I had defined among the child views within the RelativeLayout(parent layout), was causing the error.

So the way to avoid such errors in future is to keep running/checking the code as soon as you implement anything, to avoid long backtracking(which was in my case).

Hope this would be of some help!

Upvotes: 0

Pranay
Pranay

Reputation: 304

Goto gradle.properties under Gradle Scripts
then set android.enableAapt2=true
clean and Rebuild the project

Upvotes: 5

gaomode
gaomode

Reputation: 176

In my case, I just used this 'android:drawableTop="2dp"' with a TextView. Obviously, it is an invalid reference. It is a good way to revert to the last git version when met with this problem.

Upvotes: 0

Dildarkhan Pathan
Dildarkhan Pathan

Reputation: 180

I also have same error : "aapt-exe-finished-with-non-zero-exit-value-1"

In my code there was an mistake in layout xml file about drawable file name, after correct it. Its working for me.

Upvotes: 0

Rohan Lodhi
Rohan Lodhi

Reputation: 1395

Add Below Library in gradle file .

compile "com.android.support:appcompat-v7:26.0.2"
compile "com.android.support:support-v13:26.0.2"

Upvotes: 0

Syed
Syed

Reputation: 287

I also faced similar problem, got it fixed by disabling "Instant Run" option,

File>Settings>Build,Execution,Deployment>Instant Run Under Instant Run tab, disable "Enable Instant Run to hot swap code.." enter image description here

Upvotes: -1

jsbaidwan
jsbaidwan

Reputation: 31

I also faced the same issue and worked for hours on it and finally found out the solution. The drawable file that I referred in my xml was not existed. I removed the code and rebuild the project. It worked. My advice if anyone face such an issue, please look into your res folder.

Upvotes: 3

Amazonian
Amazonian

Reputation: 119

installing latest SDK/build-tool helps me.

Upvotes: 0

atitpatel
atitpatel

Reputation: 3184

Have got the same error in React Native.I upgraded the android sdk version and resulted into this.

Root cause : old version's packager collect resources.

Solution : delete directories like 'drawable-xxxx' (ATTN:no 'v?' postfix) under $(rn_project)\android\app\src\main\re.

Reference :https://github.com/facebook/react-native/issues/5787#issuecomment-236408669

Upvotes: 0

enemy123
enemy123

Reputation: 43

Upgrade your buildToolsVersion to latest and make sure your appcompactv7 import matches the sdk buildtoolversion. In my case it was buildToolsVersion '26.0.0'. Upgrading to it solved my issue.

Upvotes: 1

Swadhin Pradhan
Swadhin Pradhan

Reputation: 21

Always try to use the latest one for build tools. You have to change the line buildToolsVersion "XX.X.X" in build.gradle file (which generally resides under mobile directory in gradle 2.0) to the latest version : 23.0.2 or 24.0.2 or 25.0.2 (in my case). And then Rebuild Project. If you still have an issue, please try to update the corresponding build tool via Android SDK Manager.

Upvotes: 1

Andr&#233; Junges
Andr&#233; Junges

Reputation: 5367

If someones is using react-native (and have updated it's version recently) and having this problem:

Quoting @chamchamgo:

I found the root cause is that old version's packager collect resources (image etc.) and put under $(rn_project)\android\app\src\main\res, while newer version put them under $(rn_project)\android\app\build\intermediates\res\merged\$(buildType). It brings duplication which leads to failure of task 'processReleaseResources'. And it also explains why new created project works well. When you have an old RN project upgrading to newer version, just delete directories like 'drawable-xxxx' (ATTN:no 'v?' postfix) under $(rn_project)\android\app\src\main\res and wolrd will be nice.

Check the whole thread at: https://github.com/facebook/react-native/issues/5787#issuecomment-236408669

Upvotes: 6

Hyo Da Seo
Hyo Da Seo

Reputation: 41

Android studio only accepts images within a certain file name frame

Invalid file name: must contain only [a-z0-9_.]

I had a file by Korean. so I delete then It's worked!!!

Upvotes: 1

Freddy
Freddy

Reputation: 794

Mostly, this problem cause by wrong resource in xml file, I suggest you return your code before everything is fine. then add your new code step by step and check xml file carefully.

Upvotes: 0

user2702125
user2702125

Reputation: 141

in my case: I create new cordova project, then this aapt close in android studio, then i just update SDK Build Tools to 23.0.3 latest version. make sure you have installed MinSdkVersion & targetSdkVersion in android default 'sdk/build-tools' folder

Upvotes: 1

Ambilpura Sunil Kumar
Ambilpura Sunil Kumar

Reputation: 1463

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"
        }
    }

Upvotes: 0

reubenjohn
reubenjohn

Reputation: 1419

If the error is occuring while Gradle Processes Resources, then it is most likely an issue with your resources. Check your gradle console to make sure.

Double check any recent changes that you may have made to the res folder. In my case, I simply renamed a resource (banner.png to something_else_banner.png since banner.png must have been reserved), and it worked!

Other things I tried that failed:

  • Based on the answer by mixel, i tried to pngcrush and optipng my png that lead my to beleive that it could be an issue with my resources since the Gradle Console showed that the error occured during :app:processDebugResources FAILED.
  • Build -> clean project Build -> rebuild project failed

Upvotes: 1

Pavel Sikun
Pavel Sikun

Reputation: 11

It might be a bit too late to answer, but I didn't find a perfect answer, so here what worked for me:

  • make sure that all your files/fields in /res/ are correct.

I renamed couple of fields in attrs > declareStylable so they were pointing to non-existant enums and that's what caused a error for me.

Upvotes: 1

user5865012
user5865012

Reputation:

this error happened when you delete any resource as image which is used in any file the android studio rise this error

the solution

Build -> clean project Build -> rebuild project

good luck

Upvotes: 1

Dmitry
Dmitry

Reputation: 91

see gradle console output,

in my case - :app:processDemoReleaseResources FAILED

it was cyrillic file name in asset folder

Upvotes: 9

hermlon
hermlon

Reputation: 304

In my case I was using wrong string resource id in a layout file. After I fixed it and rebuilded the project the error was gone. Hope this helps!

Upvotes: 1

Vadym Romanenko
Vadym Romanenko

Reputation: 55

I've got the same problem. The solution was to move project folder into drive root folder. It looks like my project folder has huge path ("D:\DropBox\Dropbox\Video\Full Stack Web Development\Course 4 - Multiplatform Mobile App Development with Web Technologies\Week 3 - Deploying your App\Exercise 1\ionic\conFusion\"). After moving "Exercise 1" folder to the root of disk D, problem was gone.

Upvotes: 0

Vinit Thaker
Vinit Thaker

Reputation: 541

First try to clean and rebuild your project from Build menu.

Step 1: go to Build -> Clean Project

Step 2: go to Build -> Rebuild Project

This should solve your problem.

Otherwise try updating Android SDK build tool from SDK manager and modify your build.gradle to use latest buildToolsVersion i.e "23.0.2" as of now

Upvotes: 25

Related Questions