React-native: Execution failed for task ':app:processDebugResources'

Created on 13 Oct 2016  路  26Comments  路  Source: facebook/react-native

Hi, I am installing React Native using Window 7 and configured my Android Studio SDK according to the documentation, except for Local Maven repository for Support Libraries under Extras as this package is not found under my Android SDK Manager.

I am facing the following issue when I tried to run: react-native run-android

C:\Windows\System32\AwesomeProject>react-native run-android
JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
Building and installing the app on the device (cd android && gradlew.bat install
Debug...
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE
:app:prepareComFacebookFrescoDrawee0110Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore0110Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco0110Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline0110Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineBase0110Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp30110Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0350Library UP-TO-DATE
:app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
C:\Windows\System32\AwesomeProjectandroidappbuildintermediates\res\merged\de
bugvalues-ptvalues-pt.xml: Error: Failed to create directory: C:\Windows\Syste
m32\AwesomeProjectandroidappbuildintermediates\res\merged\debugvalues-pt
:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

C:\Windows\System32\AwesomeProjectandroidappbuildintermediates\res\merged\
debugvalues-ptvalues-pt.xml: Error: Failed to create directory: C:\Windows\Sys
tem32\AwesomeProjectandroidappbuildintermediates\res\merged\debugvalues-pt

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.

BUILD FAILED

Total time: 1 mins 4.228 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

Most helpful comment

When you're inside your project directory try using :

  • cd android && gradlew clean
  • cd .. && react-native run-android

All 26 comments

I had this problem on OSX and could solve it by running

android --clean-cache
android -update

Then it opened a window and I selected the dependencies required here. I had previously configured the SDK and selected these packages as the instructions said but these packages were 'not installed'. Then I installed them, one of them failed so I went back and selected it for installation again.

I opened up Android Studio and created a new Android Virtual Device.
Then I went to my project folder:
android adv -> Select the device you created and click start. Wait for it to load then:
react-native init YourProjectName (if you haven't already)
react-native run-android

It was the first time I could see a BUILD SUCCESSFUL message with Android, I hope it helps you too c:

@facebook-github-bot answered

You can solve this problem by installing Android SDK Platform 23 and Sources for Android 23.

My solution was to revert back to RN 0.38.0

I get a similar error -

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: Cannot create directory C:\Windows\System32\AwesomeProject\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 41.458 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

I have a Windows 10 machine - Android SDK tool version 26.0.1 , and Android SDK Platform-Tools version 25.0.5 but i still see the build fail.

@prateekvarma - It's an issue with at least RN 43 on windows. Not sure what's causing it but when building to the build folder it's not creating the full tree and then sometimes not cleaning up after itself.

A gradlew clean will fix the issue but having to do that every time you run is annoying. I also found another issue on RN 43 where if you tapped a button really really fast then it would throw an error.....something went horribly wrong in the last 8 weeks or so.

In my opinion....go with RN 38 and wait till the issues are resolved in a future release.

I encountered too... I am using 0.44.0, the problem is same.

When you're inside your project directory try using :

  • cd android && gradlew clean
  • cd .. && react-native run-android

if you are using windows

open a command, and cd to your project path
type in "npm start" but do not run it!

then open another command
enter: react-native run-android
nodejs will automatically popup

now, when the nodejs popup has the error and crash automatically, then go back the first window, press Enter!!

ok, very thing will be fine in that moment....

@Keenew cd android && gradlew clean
cd .. && react-native run-android didn't work for me .Following is some of my message:
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
AAPT: libpng error: Not a PNG file
AAPT: libpng error: Not a PNG file
Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.
Any other suggestion?Thank you!

@budiga To be honest with you i'm far from an expert in React Native, but after a quick search on stackoverflow it seems like your problem is not from react native but from a png file.
Maybe you can search in that direction or try using another image to see if that works to help you locate the issue. Hope this help :)

@Keenew thank you for your advice.I solved the problem by add two lines code in the android/app/build.gradle file,the code is the following:
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false.
I don't know how it works.

@Keenew. thanks. That worked for me

@budiga where did you found out about that, and in which part of the build.gradle did you put it?

For those who didn't know the Windows [EDIT: PowerShell, not Command Prompt] syntax:

  • cd android; ./gradlew clean
  • cd ..; react-native run-android

AAPT: libpng error: Not a PNG file
AAPT: libpng error: Not a PNG file
Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.

@budiga
I encountered this same issue. If you break it down, it's saying that there's some PNG file that it can't make sense of when it's attempting to merge in png resources into the debug build. So where might this be? I hadn't added any PNGs to my app so the logical answer was that it was a PNG added by default, which narrows it down to the PNGs used for the app icon.

Sure enough, when I checked android/app/src/main/res/mipmap-* (the locations for image resources for different screen sizes)... all the folders had corrupted ic_launcher PNGs in them.

So, to fix this, I copied an android/app/src/main/res folder from another project and overwrote the files. Then, I made sure to update the app name to the current app name inside android/app/src/main/res/values/strings.xml

Then ./gradlew clean inside /android
then react-native run-android in the project root.

Problem solved. :)

Hopefully that helps someone understand the thought proccess to fix these sorts of issues. Going line by line from an error message, walking backwards and learning what is really being said can save hours/days/weeks of struggle in the land of React Native.

If people still have problems with that, check out your path length, Windows can be a pain with that. Mine was initially pretty long and by moving my projet right on the C:\ or near the root, the prob went away.
i would do a gradlew clean in /android and then re-run react-native run-android after. Hope it helps

Following steps are work for me

1.Try code on your module build.gradle:

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

It means Android studio DO NOT check PNG strictly.

  1. Custom node_modules/react-native/react.gradle to solve the Duplicate file error perfectly. Add following code into currentBundleTask's creation block (after doFirst block)
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
}

Delete folder android/app/build

if hide some folder in project , unhide all.

I solve it uninstalling Android SDK Tools from Android Studio, after in the cmd I run the app, automatically the Android SDK Tools will be installed and the app works

Execution failed for task ':app:processDebugGoogleServices'.

Failed to create folder: D:\react-native-firebase-starter-masterandroidappbuild\generated\res\google-services\debug

help me!

Closing as the original does not have sufficient information to repro, and this issue appears to have become a catch-all for unrelated issues.

Please do feel very welcome to open a new issue, with all the necessary information, if you're still running into this.

I have try above all the solution still i don't solved the issue. Finally after one hours i have analyze the error and i got the point that something wrong with my .../User/.gradle/cashes folder and also removed my AVD and recreate it as she-dev answered as above.

Solution:
I just removed my cash data from ./gradle folder and after add android.enableAapt2=false this in gradle.properties file in my project and its work for me. I hope some will get help

@AndroidNinza @vivekkadu thanks for you,It鈥檚 all can solve my problem

Was this page helpful?
0 / 5 - 0 ratings