19

I am having a problem to build a new project. I am using React-Native and Android Emulator (AVD) but when I use the command react-native run-android I get the following message:

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':app:generateDebugBuildConfig'.

> java.io.IOException: Could not delete path 'C:\Users\diego\Desktop\Diego\albums\android\app\build\generated\source\buildConfig\debug\com'.

* 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: 2 mins 47.189 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

Here's an image of the prompt: Image of the problem

How can I fix this?

-------------------------------------------------------------UPDATE-------------------------------------------------------

I added the value C:\....\AppData\Local\Android\sdk\tools to the variable Path and I got build sucessful. Problem solved. Yay.

Thanks.

5
  • Have you read about react native documentation? I think that's pretty obvious, if you've followed the steps of this documentation: facebook.github.io/react-native/docs/getting-started.html then there's a possibility that there's an error configuring Configure the ANDROID_HOME environment variable i hope this answer can help you :) Commented Jul 20, 2017 at 18:24
  • Actually the problem was in the variable Path. Thanks :) Commented Jul 20, 2017 at 18:31
  • Thanks for the update. Helped a lot. Commented Feb 2, 2018 at 8:22
  • First try 'cd android && gradlew clean' Commented Jul 18, 2018 at 11:00
  • This solution solved my problem... Answer to--> Task :react-native-maps:compileDebugRenderscript FAILED Commented Aug 2, 2019 at 9:40

5 Answers 5

8

@diego-barreto

Added the value C:\....\AppData\Local\Android\sdk\tools to the variable Path and I got build sucessful. Problem solved. Yay.

Sign up to request clarification or add additional context in comments.

Comments

6

cd android //Navigate into the android folder from the root directory

gradlew clean // Run this

1 Comment

2

Create rn.sh file in your root of React native project with following content

 cd android/app/
 rm -rf build
 cd ..
 cd ..
react-native run-android

Then run from terminal or cmd

./rn.sh

Recommendation

VSCode must be run as Admistrator or GitDesktop must be run as Administrator

Comments

1

React Native

Faced similar issue while building react native app. Running on the different port as the default port (8081) is used by some other app.

Command to build the app.

react-native run-android --port=8082

Solution My case

(Removed extra attribute android:screenOrientation="portrait". If you check the log, it says

lineNumber: 26; columnNumber: 56; Attribute "screenOrientation" bound to namespace "http://schemas.android.com/apk/res/android" was already specified for element "activity".

hence removed the same attribute. This was being added multiple times

Error log

Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot /Users/PROJECT_PATH/node_modules/react-native/android

Task :app:generateDebugBuildConfig FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateDebugBuildConfig'.
org.xml.sax.SAXParseException; systemId: file:/Users/PROJECT_PATH/android/app/src/main/AndroidManifest.xml; lineNumber: 26; columnNumber: 56; Attribute "screenOrientation" bound to namespace "http://schemas.android.com/apk/res/android" was already specified for element "activity".

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

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
32 actionable tasks: 1 executed, 31 up-to-date
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/getting-started.html

Command failed: ./gradlew installDebug

screenshot of error

1 Comment

This help me but I don't understand why the error message is confusing with the fact that it has nothing to do with android but react server.
1

Navigate into the android folder of your react-native project and type the following:

gradlew cleanBuildCache

Then fire up something like Android Studio do a build and you should find the issue is resolved. If you still get errors check the log carefully the information is in there just hard to find.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.