[android] Android Studio: “Execution failed for task ':app:mergeDebugResources'” if project is created on drive C:

I added Google Play services as a dependency in my current project. If I save the project on the C: drive, I get the following error while syncing up the project:

Error: Execution failed for task ':app:mergeDebugResources'.
       > Error: Failed to run command:
       C:\Program Files (x86)\Android\android-studio\sdk\build-tools\android-4.4.2\aapt.exe s -i C:\Users\ashokp\Desktop\Studio\AndroidV2SDK_AndroidStudioFormat\Google Play
       Services\SampleApplication\AndroidV2SDKSampleApp_GooglePlayServices\app\build\exploded-aar\com.google.android.gms\play-services\4.3.23\res\drawable-hdpi\common_signin_btn_text_focus_light.9.png -o
       C:\Users\ashokp\Desktop\Studio\AndroidV2SDK_AndroidStudioFormat\Google Play
       Services\SampleApplication\AndroidV2SDKSampleApp_GooglePlayServices\app\build\res\all\debug\drawable-hdpi\common_signin_btn_text_focus_light.9.png
       Error Code:
       42

This only happens if the project is saved on the C: drive. If I save it to some other drive, it works perfectly.

Does anyone else face this issue? What causes this? How can I fix/circumvent this?

enter image description here

This question is related to android gradle android-studio google-play-services

The answer is


In Android Studio 1.4 with buildToolsVersion '22.0.1' the approach of fvasquezc23 worked for me with a restart and cache invalidation.

So, after you change the location of your project folder – copy/paste the folder onto disk D: (or somewhere else with no big ‘folder in folder’ structure), just

  • go to “File” -> “Invalidate Caches/Restart” (below “Synchronize”)
  • select first option “Invalidate and Restart”

add this in module's build.gradle.

android{
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false
} 

In my case

  1. I Followed This answer

  2. Changed the location of project.

  3. Tried another android device [Build and success install]

  4. Tried on my android device [Build and success install * Uninstall any previous version of same app on device]

Edit- Again it happend

I had this error message and lot of others like

x-version is deprecated and use y-version instead and it'll be removed in 2019

and all of my project started giving same error messages suddenly.

Android studio was giving warnings about my antivirus program. I tried configuring it but didn't work.

Finally I uninstalled QuickHeal antivirus from my system and all is well now


Dont make name with capital letters . Always use lowercase for naming . This will work fine . like companyLogo.png will raise error but company_logo.png will work fine.


Update your gradle build tools in project level gradle , and it will show you the exact resource that is causing the error.


Cleaning the project worked for me, Build > clean project.


Relocate the project in an outer directory.

For example from C:/Users/x/desktop/AndroidProject to C:/projects/AndroidProject.


For developers who live in Iran, Just rebuild while offline. You're done! (it's related to sanctions!)


If you are working on PC of a company that uses a proxy you must turn on your VPN


Remove any capital letters or other not allowed symbols in resource file name.

Example: activity_parkingList --> activity_parking_list


In my case, I created a folder audio in res directory. That caused the problem! Deleting the folder fixed it. Hope it might help someone.


I have a similar problem with Error:Execution failed for task ':app:mergeDebugResources. And at last I found the reason is the pictures resource error which use the incorrect ".9.png".


If you are using ionic in config.xml update widget tag with "xmlns:android="http://schemas.android.com/apk/res/android"

_x000D_
_x000D_
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">_x000D_
_x000D_
_x000D_
<widget/>
_x000D_
_x000D_
_x000D_


Adding the right repository in Project build.gradle solved the issue. In my case Google Maven Repository was needed and was added as below in the build.gradle

repositories {
google()
}

refer to this link for declaring repositories: https://docs.gradle.org/current/userguide/declaring_repositories.html


I was facing this issue after i updated to Android-Studio 3.6 the only way that worked for me was downgrading project build.gradle setting by changing

from

dependencies {
    classpath 'com.android.tools.build:gradle:3.6.0'
}

to

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0'
}

In drawable assets there was an image format which was an unsupported image. When i removed the image every thing started working fine.


I encountered the same error.

In the end, the problem was that I used an image in res/drawable that I copied in there and saved it as .png although the original file was .jpg .

I deleted the file (there's a warning message if there are still usages for the item in your code, but you can ignore it) and pasted it in with the original .jpg ending.

After a cleanup and gradle syncronization the error disappeared.


I had the same problem. Try to go to Build - Rebuild project. I didn't get that problem again and my app successfully started.


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to google-play-services

com.google.android.gms:play-services-measurement-base is being requested by various other libraries Error: fix the version conflict (google-services plugin) Google Play Services GCM 9.2.0 asks to "update" back to 9.0.0 updating Google play services in Emulator How to unpublish an app in Google Play Developer Console Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package Error "File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it" com.android.build.transform.api.TransformException How to add google-services.json in Android? google-services.json for different productFlavors