finished with non zero exit value
Asked Answered
U

42

168

I am trying to import my project. but when I run the application I am getting the following error:

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

here is my gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.example.vishnuruhela.signup"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors { }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile project(':listView1')
}
Urion answered 25/3, 2015 at 7:43 Comment(7)
Hi, were you able to fixe this problem. I'm having a similar errorCompiler
@HugoAlves hiii , still i have not slove this problem.Urion
facing the same issue did you got answerCheekpiece
@AshutoshSalodkar hiii, actually i don't found the answer,but still i understand this issue comes if you are using a library with a lower version or not compatible for your sdk and build tool versionUrion
Please share more text from exception. there should be some text describing the issue. Look for the first line of exception. It might be like OutOfMemory or duplicate lib or something. That detail will be helpful to understandSouza
The reason you have all these various answers to your question is because you have a very vague error message with a general error message. When you got that exception, there was most likely some other text in the exception that you failed to copy into your question.Cramp
I was getting the error: Process 'command 'C:\Users\admin\AppData\Local\Android\Sdk\build-tools\27.0.2\aapt.exe'' finished with non-zero exit value 1. In my case, I have strings value with character ' in strings.xml. I just replace by \' and resolve the issue.Buzz
T
162

I was getting this exact same error. I ran the command

./gradlew assembleDebug --info

Where "assembleDebug" was replaced with the assemble task for a debug version of the flavor I wanted.

Look for output

Successfully started process 'command '/usr/local/opt/android-sdk/build-tools/21.1.2/aapt''

Right below that was an error describing a resource which I used in a layout file but which was missing from the dimensions files. Fixing this fixed the build issue.

Thaumaturge answered 25/3, 2015 at 20:33 Comment(12)
where i found the file (./gradlew assembleDebug)?Chiles
i am new to android studio i don't know about that file. can u explain me how solve the issueChiles
It isn't a file. It is a command. Open a command line, navigate to your project and run that command if you are on Mac or Linux. Run "gradlew.exe assembleDebug -info" on windows I think it is?Thaumaturge
What OS are you running on?Thaumaturge
I am using emoticonProject, while compiling this. assembleDebug finish with non-zero exit value 3,Fascine
i ran that on the command line and got the same error: What went wrong: Execution failed for task ':BPIMobIntegratedPosition:processDebugResources'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/sdk/build-tools/21.1.2/aapt'' finished with non-zero exit value 1´Compiler
Run "gradlew assembleDebug --info" for WindowsRocher
Turned out to be a resource issue on my end. I was referencing a layout that no longer existed in an <include>. This helped me track down the error.Dissociation
I ran this answer and it still didnt worked got a message like Unknown source file : ERROR: In <declare-styleable> ShaderImageView, unable to f ind attribute siArrowPosition but this answer gave me the error where it could possibly be and then I spotted the error and it workedCletus
Please please put it as the right answer so others won't need to check many solutions instead of just getting the real problemMicro
This, combined with correcting the graddle version in the gradle/wrapper/gradle-wrapper.properties file, helped me spotting another issue : one of my asset path was too long.Harbaugh
Instead, you can open the Gradle pane (on my IDE, it's located on the far right side), expand your root module, then Tasks > build > assembleDebug (double click on it).Singly
W
98

At first you go to

Build -> Clean Project 

and then go to

Build -> Rebuild Project

and finish the error is a way

Wallie answered 2/7, 2015 at 8:58 Comment(8)
This didn't help at all. Misleading answer.Facula
It did't help. I am getting same error on Build -> Clean Project Arteriosclerosis
Worked for me. No idea why -- all I had done was change a single line in app/build.gradle that shouldn't have affected resources.Jenn
Definitely not misleading - I swapped an mp3 file for an ogg one and got the same error, this solved it.Priscilapriscilla
Solves issues where you change the extension of a resource without changing it's name.Gunilla
I meet this problem when I write <attr name="textSize"/>, I forget format="dimension".Ankylostomiasis
Please avoid giving this as an answer, as it doesn't answer the question directly. You should comment this instead of an answer.Mccallister
This does not work for me too. Considered downvoting as a better action.Mieshamiett
I
48

Install the latest version of the build tools. Adjust your build.gradle to use

android {
    compileSdkVersion {X}
    buildToolsVersion "{X.Y.Z}"
   ...
}

Proper values should match your installed SDK. Could be 23.0.3 at the time of this post.
or check and remove duplicate dependencies from list.

Enjoy :)

Intensify answered 3/4, 2015 at 11:56 Comment(8)
How did you know this? And how is that error useful?Elaboration
because i faced this kind of problem & gradle suggest for this.Intensify
Hi I set buildToolsVersin"22.0.1" still facing this issueHb
@Ramani... This doesnt solve issue... could you tell me in what cases this issue occurs.Kabob
my problem soled by remove one of gradle dependencies library, from project properties dependenciesLemon
Hi I have buildToolsVersin"22.0.1" still have this issueScevour
Changing to v 23.0.3 worked for me in android studio thanks you.Coherent
This was the solution for me. Thank you!Baptistry
L
17

Follow this simple steps to recover this error:

Method 1:

-Go to File->project structure->Project
-Check Android plugin Version and change it to 1.3.0(Latest one)
-Go to File->project structure->app->Properties->Build Tools Version
-Change it to latest one(22.0.1). Also do this for any other module you have for your project.
-Clean and build project.

Note: If your build tool version is less than 22.0.1 then you may still face same error while gradle build so please update your SDK from SDK Manager to latest one then restart android studio and follow above steps.

Method 2:

-If you don't want to update build tools version or you don't have latest SDK version just Go to File->project structure->Project.
-Check Android plugin Version and change it to 1.0.0(Older one)
-Clean and build project.

I recommended Method 1.

Lignin answered 2/9, 2015 at 10:32 Comment(3)
helped me,+1 from me :)Schema
@Lignin its good and also work alomsat ever time but its not working this time.Urion
@ankur what issue you faced ?Have you update latest build tool and gradle plug in?Lignin
C
15

I had the same problem after replacing some .png image resources with .jpg pictures.

I deleted appname/app/build, than I selected Build -> Rebuild project and finally it worked without any errors.

Certain answered 20/5, 2015 at 23:14 Comment(1)
I had the same issue, I cleaned the project and solved, I faced this issue after replacing png drawables with jpg with the same name.Moya
A
7

In my case, answers of taciosd and Netero pointed in the correct direction. By analyzing:

gradle assembleDebug --stacktrace --debug 

Linux:

./gradlew assembleDebug --stacktrace --debug

i found out that one filepath in the assets folder was too long and aapt.exe stopped by returning 1 (and no specific error message) when processing that file. It seems that files with non ASCII characters in names are not accepted as well.

Arakawa answered 8/7, 2016 at 13:33 Comment(2)
That was exactly my case. Thanks a lot! It seems there are bug reports of this issue as early as february 2015, but it's still failing. Now I have to change all those asset file names somehow, what's sort of a pain because they're auto-generated based on the information gather from a DB that uses seven different languages. I could understand these problems back in the 80s and even 90s, but gosh, we are in 2016 and Unicode is not well supported??? What a bad joke, really.Delanadelancey
JFTR, this is the error I get from aapt: "küchen.dat: error: Invalid filename. Unable to add." Incidentally it is the first asset that has no-ascii chars in its file name. Beside that one that's in german, I have dozens in Spanish, French, Portuguese and even Russian... this sucks.Delanadelancey
M
6

I had this same exact error all of a sudden the other day. I did a "Clean Project" and a "Rebuild Project" and never saw the error again.

I've only got a few months of Android development under my belt. But whenever I get an unexplained error like this, "Clean Project" and/or "Rebuild Project" are the first things I try.

Monstrance answered 18/4, 2015 at 0:40 Comment(0)
L
5

i had the same problem i resolve it by removing files that i added in the assets folder and those files name contains insupported characteres like "é" , " ", "ï" "è"... by renaming those name files or removing them you will have no problem.

Lactose answered 26/5, 2015 at 13:46 Comment(2)
This was my issue. I added a bunch of files in the assets folder and didn't realize that one had some "é" etc.Prue
Thanks, you gave me an idea. I had an un-escaped char in my strings.xml - very long line, lint haven't showed itSelfidentity
D
5

BuildToolsVersion & Dependencies must be same with Base API version.

buildToolsVersion '23.0.2' & compile 

&

com.android.support:appcompat-v7:24.0.0-alpha1

can not match with base API level.

It should be

compile 'com.android.support:appcompat-v7:21.0.3'

Done

Dodona answered 29/4, 2016 at 11:15 Comment(0)
I
4

Errors in the execution of aapt in task processDebugResources or processReleaseResources generally happen when one or more resources of your project are unsupported.

To find out go to the root dir of your project and run:

gradle processDebugResources --debug

This will print aapt specific error. In my case it was a file in the assets folder whose name had invalid character (LEÃO.jpg). aapt doesn't support some characters in the Latin alphabet.

But, as I explained your problem can be other than that. To know for sure you have to run processDebugResources with the option --debug.

Ingressive answered 7/5, 2016 at 21:41 Comment(1)
This really helped. When running with --debug it may output lots of stuff so you can search for "error: Invalid filename. Unable to add." to identify the file that is causing the troubles.Lammergeier
S
4

I have faced the same error while compiling. I tried all the methods here but failed only one thing worked but it takes a lot of time. by running this code on CMD to debug my app and shows me the missing tag in my XML layout.

gradle processDebugResources --debug

The best approach is to analyze the error not just ignoring it.

To run this code I installed Java JDK and then set Environment Variable: for JAVA_HOME and Gradle.

for gradle

C:\Program Files\Android\Android Studio\gradle\gradle-4.6\bin

for java

JAVA_HOME=C:\Program Files\Java\jre1.8.0_191
Sashasashay answered 10/11, 2018 at 8:10 Comment(0)
B
3

You have to do the following instructions :

Click on Build located in the toolbar, then

Clean project -> Rebuild Project

Barye answered 27/8, 2015 at 13:20 Comment(0)
L
3

enter image description here

Please make sure that compileSdkVersion, buildToolsVersion and targetSdkVersion have the same version number. I also have this error because it has different version. This solution worked for me.

I hope it can help you all.

Liszt answered 11/9, 2018 at 7:13 Comment(0)
S
3

when our code has layout.xml file error ,we get this error message. Check your xml files again.

Stogy answered 20/2, 2019 at 11:29 Comment(0)
W
2

look through your styles.xml files for a @+id/ I had one in styles.xml in values-v17 which I don't recall creating. This is what I had to change in the end and not build tools 21.1.2 to 22.0.1 as suggested.

Wordy answered 29/4, 2015 at 21:42 Comment(0)
K
2

I also had the same error with my images .. Just rename the extension from ".png" or whatever you have to ".jpg"

Kuebbing answered 3/7, 2015 at 4:56 Comment(0)
L
2

I had the same problem.

Try renaming the files in assets folder with characters other than alphabets, numbers and underlines.

Specially, look for apostrophes and European alphabets not common in English.

Lambda answered 7/2, 2016 at 7:57 Comment(1)
Gzipped files in my assets directory caused this for me.Irishirishism
H
2

I build with command:

./gradlew build --info

It show more error message, my problem is there is special characters in the file name.

Howlend answered 8/4, 2016 at 14:50 Comment(0)
E
2

I too was facing this issue just because i had renamed my project folder while project was opened in Android Sudio.So,Android Studio created another folder in that directory of my window.

I found in my build.gradle(Module:app), all the support libraries were updated and was throwing error on compile time of project.

All you require to do is,simply change updated support libraries to your current build tool version like this and rebuild the project.

compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'

my current build tool version is 22.2.1

Eldwin answered 14/6, 2016 at 7:9 Comment(0)
J
2

When i replace the images in project then i get this issue. Then i found that one of the image was having extension .PNG then i rename it to .png then my issue was resolved. Hope it helps you

Jubilee answered 6/9, 2016 at 7:40 Comment(0)
S
2

I had this same problem, and it only went away after a removed the .gradle folder from my project's root.

So make sure you:

  1. Close the project in Android Studio
  2. Open your file explorer, find the project's root directory
  3. Completely remove the folder .gradle

I hope this helps. Good luck!

Singly answered 6/4, 2017 at 13:27 Comment(0)
O
1

I was also getting this issue.

  • I generally face this issue when I import some sample or already existing module into my project.
  • I just added latest v7 and v4 to my project from maven in android studio and got it fixed
  • Removed duplicate dependencies from project like wise if your library project and application project are using v7 or v4 or any other library , they should be of same version. or try to have it only in your library project
Octroi answered 13/5, 2015 at 13:9 Comment(0)
N
1

I had the same problem. Even JPG files did not work. Put all your image files into mipmap and work. They work perfectly.

Newton answered 22/7, 2015 at 6:26 Comment(0)
P
1

I ran to same problem today and try to clean and rebuild project.

I did not solve my problem. I got it solved with change the compileSdkVersion, buildToolsVersion, targetSdkVersion and com.android.support:appcompat-v7:23.0.1 values instead on my Gradle app file. Then I ran clean and rebuild the project afterwards.

Pignut answered 15/9, 2015 at 5:57 Comment(0)
S
1

For return value 3 "OutOfMemory exception" i added following in gradle android section

android {
............
dexOptions {
    incremental = true;
    preDexLibraries = false
    javaMaxHeapSize "4g" // 2g should be also OK
}
............
}

And for 2nd issue with return value 2, earlier i had following in gradle dependencies for JDK 7

compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:7+'
compile 'com.facebook.android:facebook-android-sdk:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:support-v4:+'

Then i updated my JDK to 8 and it started to give me error (probably for jdk 8 there were more than one libs available with 7+ ) while running the application. What fixed my issue is giving specific version instead of 7+. i.e.

compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
Souza answered 31/12, 2015 at 16:8 Comment(1)
You were getting out of memory here because you included all the play services. You can read about splitting the dependencies into the packages you actually need.Cramp
A
1

In my case, I had to install "libz.so.1" library to make it work, on Ubuntu 15.04

sudo apt-get install lib32z1
Andvari answered 23/2, 2016 at 15:30 Comment(0)
M
1

Error:Execution failed for task com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:

finished with non-zero exit value 1 One reason for this error to occure is that the file path to a resource file is to long:

Error: File path too long on Windows, keep below 240 characters

Fix: Move your project folder closer to the root of your disk

Don't:// folder/folder/folder/folder/very_long_folder_name/MyProject...

Do://folder/short_name/MyProject

Another reason could be duplicated resources or name spaces

Example:

<style name="MyButton" parent="android:Widget.Button">
      <item name="android:textColor">@color/accent_color</item>
      <item name="android:textColor">#000000</item>
  </style>
Monmouthshire answered 12/9, 2016 at 19:18 Comment(0)
C
1

In my case this error was caused by empty layout xml file.

I created the empty file but forgot to add any content to it. AndroidStudio gave this misleading error message, but when I executed the gradle build from command line I could see the real error like "Error parsing XML: no element found" and the file name.

Adding basic layout xml content fixed the error.

Candra answered 21/3, 2018 at 13:32 Comment(0)
H
1

look the compileSdkVersion at android/biuld.gradle ,and compileSdkVersion in all other packages should be the same.

Hospers answered 23/7, 2018 at 8:2 Comment(0)
O
1

just for the record. I followed all clean/rebuild and update SDK-Tools here, but in the end it turned out disable Instant Run, to solve my issue.

Go to: Android Studio -> Preferences -> Build,ExecutionDeployment -> Instant Run

Oreopithecus answered 4/2, 2019 at 16:22 Comment(0)
L
1

Make sure you choose to build a variant as 'Release' on Android Studio.

enter image description here

Lechery answered 22/11, 2020 at 15:52 Comment(0)
K
0

Please make sure your gradle build your compileSdkVersion has its sdk installed in your project. Then just reload your project everything should be fine.

Kriss answered 22/4, 2015 at 11:19 Comment(0)
D
0

Looks like it could be caused by different root causes. While in my case, it's caused by "Windows OS cannot handle the path which is too long", so the "aapt.exe" reported that error message:

http://start-coding.blogspot.com/2015/07/android-development-in-windows-using.html

Decretive answered 13/7, 2015 at 3:25 Comment(0)
S
0

Make sure that your min/targetSdkVersions are the same in build.gradle and manifest (if exist). Also check for buildToolsVersion in all your modules - it must be the same.

Subtonic answered 1/4, 2016 at 19:8 Comment(2)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From ReviewApthorp
@MayankPatel This looks like an answer to me. This is in no way a question. If you think that this answer is wrong, then you can downvote it, but please don't abuse your delete privileges in this review queue.Massotherapy
A
0

just solved this issues with moving the project to a shorter path. It can happen if you exceed the Windows max path length

Amatol answered 11/4, 2016 at 8:16 Comment(0)
S
0

Under Centos7 64 bit the issue is that some 32 bit libraries did not exist. To fix this I need to add:

yum install glibc.i686
yum install zlib.i686
yum install libstdc++.i686
Spiegleman answered 29/4, 2016 at 13:10 Comment(0)
E
0

For anyone who is trying to use the NDK for the first time, install the NDK via Android Studio's SDK Manager. After I did that the error went away.

Previously I had been following other tutorials/posts that just said to download the NDK yourself, but no one said where to put it. Letting Android Studio handle it fixed the error and allowed my app to launch.

Equivalency answered 16/7, 2016 at 6:48 Comment(0)
V
0

its been a while but hope it helps

For me it was just something missing from @dimens which was used in xml file it was weird that android studio didn't mention it directly in error

Vantage answered 30/4, 2019 at 9:21 Comment(0)
A
-1

build from command line with --debug (gradlew build --debug).

look for error near end.

Avram answered 19/6, 2016 at 20:47 Comment(0)
S
-2

I had the same problem when writing layout file, after I deleted these two lines:

android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"

the errors were gone.

Spare answered 24/4, 2016 at 16:5 Comment(0)
R
-3

1)100% working solution is

step 1) go buid option in menubar step 2) clean build step 3) rebuild it

sucessfully get it guys enter image description here

Rube answered 12/10, 2015 at 8:12 Comment(1)
That's the same as the highest voted answer. Please don't duplicate answers. Instead you should include new content.Massotherapy
C
-3

Just Make The Changes in The main/AndroidManifest.xml file. check for the tags and the values supplied i did this and all errors were removed

Croix answered 20/7, 2016 at 6:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.