I am new in react native so please help me start with that .I just create my first react-native project by using this command
npx react-native init AwesomeProject
I already install android studio and add path of sdk in environment. Also done with developer option in my android. When I run that command
npx react-native run-android
it gives me a lot of errors like that
* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'E:\react_native\AwesomeProject\android\local.properties'.
* 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 7s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Go to the android/ directory of your react-native project
Create a file called local.properties with this line:
sdk.dir = /Users/USERNAME/Library/Android/sdk
Where USERNAME is your macOS username
More Info found here
Related
I have a problem with building react native app on android emulator. I tried to crate app with Expo and everything works great on android device, android emulator(Android studio) and web. But when I try to create with React Native CLI a have a build error.
admin#users-MacBook-Pro secondProjectReactNative % npx react-native run-android
warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
info Starting JS server...
/bin/sh: adb: command not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/admin/secondProjectReactNative/android/local.properties'.
* 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 3s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/admin/secondProjectReactNative/android/local.properties'.
* 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 3s
at makeError (/Users/admin/secondProjectReactNative/node_modules/execa/index.js:174:9)
at /Users/admin/secondProjectReactNative/node_modules/execa/index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (/Users/admin/secondProjectReactNative/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/admin/secondProjectReactNative/node_modules/#react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
What can be wrong? Thanks a lot.
I did everything what was in react native CLI quick start https://reactnative.dev/docs/next/environment-setup
I'm sure that PATH is added
admin#users-MacBook-Pro secondProjectReactNative % echo $PATH
/Users/admin/.rvm/gems/ruby-2.7.5/bin:/Users/admin/.rvm/gems/ruby-2.7.5#global/bin:/Users/admin/.rvm/rubies/ruby-2.7.5/bin:/Users/admin/.rvm/bin:/usr/local/opt/ruby#2.7/bin:/usr/local/opt/ruby#2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/opt/ruby#2.7/bin:/Users/admin/Library/Android/sdk/tools:/Users/admin/Library/Android/sdk/platform-tools:/Users/admin/Library/Android/sdk/emulator:/Users/admin/Library/Android/sdk/platform-tools
I downloaded SDK through Android Studio.
Start android studio emulator before "run android" doesn't help.
I am making my first react native app and I have had to eject from Expo to add in app purchases.
I have gotten the error below and not quite sure what to do when running:
react-native run-android
I have tried adding "C:\Users\Marc\AppData\Local\Android\Sdk" as PATH environmental variable but has not solved the issue
Any ideas on what to try next?
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Marc\Desktop\Swig\node_modules\react-native-reanimated\android\build.gradle' line: 89
* What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\Marc\Desktop\Swig\android\local.properties'.
* 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 1m 24s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
I had added the address to the PATH variables rather then its own
https://reactnative.dev/docs/environment-setup
operating system: Ubuntu 18.04 lts
I'm using vscode
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/myworldsoftware-u/İndirilenler/project2/android/local.properties'.
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
BUİLD FAILED in 8s
at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at runOnAllDevices (/home/myworldsoftware-u/İndirilenler/project2/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
at buildAndRun (/home/myworldsoftware-u/İndirilenler/project2/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/home/myworldsoftware-u/İndirilenler/project2/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Had the same issue when I cloned a react-native repo to Linux and tried to run the app in the emulator. First is to have all your environment up and running. If that is the case, for me it was the permission issue for the gradlew file. Go to the android folder in your app and: chmod +x gradlew This answer was provided by Badmus Taofeeq in the post Clone and run react native projects from GitHub.You can also see on that page which commands to run to start the app. Hope you find something useful in this.
C:\Users\hp\Desktop\Reactprojects\Makerobos>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\hp\Desktop\Reactprojects\Makerobos\android\local.properties'.
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 5s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\hp\Desktop\Reactprojects\Makerobos\android\local.properties'.
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 5s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (C:\Users\hp\Desktop\Reactprojects\Makerobos\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (C:\Users\hp\Desktop\Reactprojects\Makerobos\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at C:\Users\hp\Desktop\Reactprojects\Makerobos\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Command.handleAction (C:\Users\hp\Desktop\Reactprojects\Makerobos\node_modules\react-native\node_modules\#react-native-community\cli\build\cliEntry.js:160:7)
Your SDK path is not correct you need to add a correct path in the below file:
sa
project > android > local.properties
Add the path like below example:
sdk.dir = /Users/admin/Library/Android/sdk
After added use the following commands:
1. cd android/
2. ./gradlew clean
3. cd ..
4. Command: react-native bundle --platform android --dev false --entry-file indexcsasa.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
csacs
5. react-native run-android
Sometimes the build fails, but it still runs .Have you tried connecting your app via the WIFI to the remote server? Check the connect via wifi method React connect via Wifi
I guess that will work
I am trying to run the react-native run-android command in window 10. I set up the path to the SDK folder using ANDROID_HOME in System Variables of Environment Variables
ANDROID_HOME | C:\Users\owner\AppData\Local\Android\Sdk
And I also set up sdk.dir in the local.properties file
sdk.dir=C\:\\Users\\owner\\AppData\\Local\\Android\\Sdk
However, when I run the command lines
react-native run-android
in my project folder C:\Users\owner\Documents\React_Native\MyApplication> It gave me an exception as follow.
C:\Users\owner\Documents\React_Native\MyApplication>react-native run-android
Scanning folders for symlinks in C:\Users\owner\Documents\React_Native\MyApplication\node_modules (34ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* 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: 5.305 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