I have gone through every similar question on here but can't find a solution. I am testing out react-native on my xubuntu 18.04 and I'm stuck on the last step of launching the app on my phone. I have installed android-sdk and it is located in /usr/lib/android-sdk,
I also see my device attached when I do adb devices
I have added the below inside the .bashrc file and have done $ source ~/.bashrc and restarted the terminal and tried running the app again
export ANDROID_HOME=/usr/lib/android-sdk
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/build-tools/24.0.0:$PATH
I keep getting:
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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
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
I also tried the local file approach with local.properties file and adding sdk..what am I doing wrong here?
Please check the version of the sdk installed and the version of the sdk in the gradle
It should be the same.
It worked for me when giving the same versions.
Related
I'm new to WebStorm and React Native and I encountered an error while setting up my environment that appears unique compared to the other post I've seen.
Objective
I've set up a default project in WebStorm, my goal is to run that project on an Android emulator, I'm using a Windows PC.
What I've tried
I've set up a simple Debug configuration in WebStorm
I've also downloaded an Android Emulator thru Android Studio and I have it running on my computer.
Now when I click on run for my debug emulator I get the following error:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
infoerror Installing the app...
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.
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\Nicol\WebstormProjects\Dog\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 13s
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\Nicol\WebstormProjects\Dog\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 13s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (C:\Users\Nicol\WebstormProjects\Dog\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
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.
Other Information
Here is a picture of my Path System variables:
adb is not on your %PATH%; make sure to add the folder where adb.exe is located (usually $ANDROID_HOME/platform-tools, where $ANDROID_HOME is your Android SDK install dir, usually C:\Users\Your.Name\AppData\Local\Android\sdk, you can run where adb command in Windows cmd console to find it) to %PATH% under System environment variables and then restart WebStorm.
You also need defining %ANDROID_SDK_ROOT% environment variable per suggestion in the error message
Just to add, windows environment variables are case sensitive and adding %LOCALAPPDATA%\Android\Sdk like the react-native website says will not work, you need to add %localappdata%\Android\Sdk
I build an app on Ionic framework, it works on the browser but when I try to compile it on the emulator I have got this error:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\user\AppData\Local\Android\Sdk (DEPRECATED)
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/5.3.1/userguide/gradle_daemon.html
Process command line: C:\Program Files (x86)\Java\jdk1.8.0_201\bin\java.exe -Xmx2048m -Dfile.encoding=windows-1252 -Duser.country=SA -Duser.language=ar -Duser.variant -cp C:\Gradle\gradle-5.3.1\lib\gradle-launcher-5.3.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.3.1
Please read the following process output to find out more:
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
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
C:\Gradle\gradle-5.3.1\bin\gradle: Command failed with exit code 1
[ERROR] An error occurred while running subprocess cordova.
cordova run android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
This is because the path to Android Sdk is not set correctly. Please check the correct path for Sdk, tools, platform-tools, emulator and Android build-tools.
Please, realize that the configuration recommended for Ionic has changed a
bit. Now the notation recommended is as follows:
ANDROID_SDK_ROOT=/home/username/Android/Sdk (recommended setting)
ANDROID_HOME=/home/username/Android/Sdk (DEPRECATED)
In Linux or Mac OS X configure the path into the ~/.bashrc, ~/.bash_profile file:
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools
At the end, after save the configuration dont forget to do the command:
source ~/.bashrc
or as your case
source ~/.bash_profile
For the Windows users check the global variables.
Try to Run npm cache clean and re-install cordova...worked for me.
I finally found the solution from a related solved topic: The solution is:
ionic platform rm android
ionic platform add android#latest
ionic resources
ionic run android
ionic repair worked for me. Just give it a try and see if that works for you. Good luck!
I'm new in React-Native. I tried several solution in some forums but didn't help. Bellow the errors .
Microsoft Windows [Version 10.0.17134.407]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\xampp\htdocs\Hands-on React-Native\TripPlane>react-native run-android
Starting JS server...
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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 19s
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
You need to setup ReactNative properly.
I have consider that android studio is already installed and emulator or android device is already attached
Follow below steps!
1] Install JDK from official site
2] Install NodeJs from official site
3] Install Python 2 form official site
4] Install ReactNative CLI , open CMD [ right click and run as administrator ]
Type C:\WINDOWS\system32>node -v // to get node version
Type C:\WINDOWS\system32>npm install -g react-native-cli // to install RN CLI
5] Create workspace of your RN projects
- D:\ReactNative>react-native init projectname //it will generate project inside mentioned path.
6] setup environment variable
set up new variable under user variable (if not exist) JAVA_HOME with the value
C:\Program Files\Java\jdk-10.0.2 (your JDK path)
set up new variable under user variable (if not exist) Path with the value
C:\Users\Admin\AppData\Local\Android\sdk\platform-tools //your sdk platform tools path
7] run your project using following command inside CMD
D:\ReactNative>react-native run android
I just created a new project using command palletes in vsCode. then i start android simulator and then flutter run. it's running perfectly on ios not on android .
this debug console response
Launching lib/main.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAidl'.
java.lang.IllegalStateException: aidl is missing from '/Users/sachin/Library/Android/sdk/build-tools/26.0.2/aidl'
* 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 1s
Gradle build failed: 1
Exited (sigterm)
Just now I encounter the same problem. It happened because after doing "flutter run" there's still some file that needs to be downloaded, the build tools, but didn't get downloaded correctly, because I stopped it in the middle, since I thought the process was stuck.
So, these are the steps that solve the problem:
open terminal
change directory to /Users/[USERNAME]/Library/Android/sdk/build-tools/, in your case, type cd /Users/sachin/Library/Android/sdk/build-tools/
remove the folder that causes the error, in your case the 26.0.2 folder, so in your terminal type rm -r 26.0.2 to remove it.
go back to your code, make sure the android simulator is detected, and re run the project
now, wait patiently, it may takes sometime (depends on internet connection), but it's downloading the build tools, you can watch this in the finder by typing open .
make sure that in the 26.0.2 folder there's aidl file added when the process is finished.
it should be working, if not, just rebuild/re-run your code one more time. Done!
Having huge issues trying to build to android with Ionic. I tried initially the normal ionic build android, it failed with
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
I did some hunting around stack overflow and ionic forums, and installed Java and Android Studio as a 'solution', it began to install lots of .jar files, and this happened:
Download https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
Download https://repo1.maven.org/maven2/commons-codec/commons-codec/1.4/commons-codec-1.4.jar
Download https://repo1.maven.org/maven2/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar
Download https://repo1.maven.org/maven2/org/abego/treelayout/org.abego.treelayout.core/1.0.1/org.abego.treelayout.core-1.0.1.jar
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/.../Library/Android/sdk
* 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: 51.558 secs
Error: /users/nick/documents/.../.../platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /Users/.../Library/Android/sdk
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please install Android target: "android-23".
Hint: Open the SDK manager by running: /Users/.../Library/Android/sdk/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
Any advice? Maybe I need to un-install Android Studio or something? I'm very bad at this, as you likely can tell. But this is hugely holding back the project I'm working on, so will be amazing if someone could help!
Base from Installing the Android Development Environment
Configure the ANDROID_HOME environment variable based on the location of the Android SDK. Additionally, consider adding ANDROID_HOME/tools, and ANDROID_HOME/platform-tools to your PATH.
For Mac :
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
For windows :
set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
For linux :
export ANDROID_HOME=/<installation location>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools