简体   繁体   中英

Gradle build error using react native

I get this error when trying to run an app on an android emulator(Android Studio) from a console window:

$ react-native run-android Scanning folders for symlinks in C:\\Users\\Brian\\desktop\\codervets\\arrive-alive\\aa_app\\node_modules (27726ms) Starting JS server... Building and installing the app on the device (cd android && gradlew.bat installDebug)... Starting a Gradle Daemon (subsequent builds will be faster) Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'.

    The SDK directory 'c:\\Users\\eelia001\\AppData\\local\\android\\sdk1' does not exist.

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

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

BUILD FAILED in 4m 51s 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

And yet my sdk directory in android studio has the following directory: C:\\Users\\Brian\\AppData\\Local\\Android\\Sdk

Has anyone else ran into this issue? If so, how do I fix it?

The error states:

The SDK directory 'c:\\Users\\eelia001\\AppData\\local\\android\\sdk1' does not exist.

And you say your SDK is in:

C:\\Users\\Brian\\AppData\\Local\\Android\\Sdk

Since those aren't the same directory, my guess is that's the problem. Are you perhaps logged in as the wrong user? You're going to want to check that ANDROID_HOME is set correctly.

So I'm not sure why it was setup the way it was, but the way to fix it is to go to Advanced System Settings → Environment variables. Thank you to @Rich Churcher for the link to a proper tutorial (it's outdated but the steps worked).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM