Command failed: gradlew.bat installDebug

前端 未结 8 2104
太阳男子
太阳男子 2020-12-11 06:50

While developing an app I came into following error. I tried downgrading the java version from 11 to 8, but that wasn\'t helpful.

FAILURE: Build failed with          


        
相关标签:
8条回答
  • 2020-12-11 07:23

    I had this issue myself, it eventually went away after I uninstalled and re-installed android studio and gradle, but a few other things you could try first

    1: Setting GRADLE_USER_HOME in environment variables (if on windows)

    2: Downgrade to react-native 0.57.0

    3: Make sure you have the correct permissions to run the command and access files

    4: Make sure your gradle files are synced correctly, and that location of gradle and the android skd are correct within project structure offline mode

    5: Check gradle for updates

    (Assuming you are using android studio)

    Good luck

    0 讨论(0)
  • 2020-12-11 07:26

    open your 'settings.grandler' file in the android folder

    change the '\' to '/'

    save the file

    run the command 'react-native run-android

    0 讨论(0)
  • 2020-12-11 07:30

    Try running this command inside your project file

    react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res 
    

    after that

    cd (path to project/android folder) && gradlew clean && cd .. && react-native run-android
    

    always gradlew clean before run react-native-run-android the above command basically cleans up the gradle and previous builds.

    for ENOENT Error Check if $ yarn start works. The metro bundler wasn't able to run on port 8081 for me and I needed to run $ killall node

    EDIT:

    Also update the gradle-wrapper.properties add

    distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

    remove following code from build.gradle:

    task wrapper(type: Wrapper) {
       gradleVersion = '5.2.1'
       distributionUrl = distributionUrl.replace("bin", "all")
    }
    

    after that

    cd (path to project/android folder) && gradlew clean && cd .. && react-native run-android
    

    always gradlew clean before run react-native-run-android the above command basically cleans up the gradle and previous builds.

    You're good to go!

    0 讨论(0)
  • 2020-12-11 07:35

    How I solved this problem:

    First, make sure that I have %java_home% variable set and also %path% has the java sdk included. How to setup Java environment variables

    Second, Go to your android folder and run this command:

    C:\Projects\myproject\android>gradlew.bat app:installDebug.
    

    Unzipping C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip to C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv Exception in thread "main" java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:225) at java.util.zip.ZipFile.(ZipFile.java:155) at java.util.zip.ZipFile.(ZipFile.java:169) at org.gradle.wrapper.Install.unzip(Install.java:215) at org.gradle.wrapper.Install.access$600(Install.java:27) at org.gradle.wrapper.Install$1.call(Install.java:75) at org.gradle.wrapper.Install$1.call(Install.java:48) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

    As you can see that my gradle download is corrupt. All you have to do is delete this folder and rerun the command.

    C:\Projects\myproject\android>gradlew.bat app:installDebug
    

    Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip ............................................................................................................... Unzipping C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip to C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv

    Welcome to Gradle 4.10.2!

    Here are the highlights of this release: - Incremental Java compilation by default - Periodic Gradle caches cleanup - Gradle Kotlin DSL 1.0-RC6 - Nested included builds - SNAPSHOT plugin versions in the plugins {} block

    For more details see https://docs.gradle.org/4.10.2/release-notes.html

    Now, you can go back to your react native project and run

    react-native run-android
    

    info JS server already running. info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...

    Task :app:installDebug 01:03:18 V/ddms: execute: running am get-config 01:03:18 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1 01:03:18 V/ddms: execute: returning Installing APK 'app-debug.apk' on 'Pixel_2_API_28(AVD) - 9' for app:debug 01:03:18 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554' 01:03:18 D/Device: Uploading file onto device 'emulator-5554' 01:03:18 D/ddms: Reading file permision of C:\Projects\xx\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------ 01:03:18 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:03:19 V/ddms: execute: returning 01:03:19 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:03:19 V/ddms: execute: returning Installed on 1 device.

    BUILD SUCCESSFUL in 9s 27 actionable tasks: 1 executed, 26 up-to-date info Running C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 info Starting the app on emulator-5554 (C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 shell am start -n com.myproject/com.myproject.MainActivity)... Starting: Intent { cmp=com.myproject/.MainActivity }

    0 讨论(0)
  • 2020-12-11 07:35

    Just run sudo react-native run-android and it will build and install ./gradlew app:installDebug inside android directory for you.

    0 讨论(0)
  • 2020-12-11 07:35

    The problem is on file:

    nameyourapp/android/local.properties

    you have to substitute with the correct path: /Users/nameUser/AppData/Local/Android/sdk

    0 讨论(0)
提交回复
热议问题