firas chmek
firas chmek

Reputation: 47

Unable to set layout background from drawable

I'm unable to set my MainActivity background from a drawable image:

android:background="@drawable/loli"

loli is my drawable name. Actually nothing special, just the usual to get a simple background. When I use it my xml, I'm getting this error while running:

Error:Error: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/firas/Android/Sdk/build-tools/19.1.0/aapt'' finished with non-zero exit value 42
:app:mergeDebugResources FAILED
Error:Execution failed for task ':app:mergeDebugResources'.
> /home/firas/AndroidStudioProjects/NeverLost/app/src/main/res/drawable/back.png: Error: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/firas/Android/Sdk/build-tools/19.1.0/aapt'' finished with non-zero exit value 42

Upvotes: 0

Views: 415

Answers (3)

firas chmek
firas chmek

Reputation: 47

Thank you everyone for your answers the links you provide me were very useful (first one). actually the problem was not changing the image extension . because I was saving .jpeg extensions as .png from google image I think it's much suitable to keep the default extension . At least that worked for me

Upvotes: 0

Mohammad Tauqir
Mohammad Tauqir

Reputation: 1815

This can happen when gradle fails to process resources. In your case it may have happened to be an invalid image file in the drawable folder.

Please check both ways

1> check your extension & convert them .png into .jpeg

2> if that useless then delete from drawable

Please visit Android Studio Error: org.gradle.process.internal.ExecException or this link for more help Android Studio crash (aapt.exe returns 42) when I put PNG file in drawable folder

Upvotes: 1

ayz4sci
ayz4sci

Reputation: 2248

Try cleaning/rebuilding your project.

Build > Clean Project or Build > Rebuild Project

Upvotes: 0

Related Questions