React Native adb reverse ENOENT - android

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync
Here is a log
JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.
* 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: 3.785 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
NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.
I found my android emulator when executing adb devices
List of devices attached
192.168.56.101:5555 device
I have tried the following steps from Stack Overflow post, but still no luck
https://stackoverflow.com/a/38536290/4540216

I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.
Follow this React-native android-setup documentation
ex:
export ANDROID_HOME=~/Library/Android/sdk
Windows:
set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk
macOS Mojave and earlier or bash users:
1 - Open your bash profile:
open .bash_profile
Add this to your bash_profile:
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.bash_profile
For macOS Catalina and zsh users:
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
On your Mac:
Open your .zshrc file:
open ~/.zshrc
If .zshrc file not exist, you need to create one using touch & open.
touch ~/.zshrc
Add this to your .zshrc file
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.zshrc
Edit: Updated answer for macOS Catalina and zsh users.

Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
More details on zsh from Apple
So on your Mac:
1 - Open your .zshrc file:
open ~/.zshrc
2 - if .zshrc file doesn't exist, you need to create one & open again(Step 1)
touch ~/.zshrc
3 - Add this to your .zshrc file(Add JAVA_HOME to use Android Studio Embedded JDK)
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export ANDROID_HOME=/Users/<your_computer_name_here>/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
4 - Save and close
5 - Compile your changes
source ~/.zshrc
& make sure to restart your terminal.

I also got the same issue. And I updated my ANDROID_HOME env variable again in same cmd and it was worked fine.
> export ANDROID_HOME=~/Android/Sdk
> export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
good luck

this was my solutions
operating system: Linux mint
sudo apt-get install android-tools-adb

This answer is for MacOs Catalina or above user or zsh users as your Mac now uses zsh as the default login shell and interactive shell.
This is related to path issues.
If you follow along with the docs of React Native Setting up the development environment guide. Then do the following.
Open ~/.zshrc using editor. In my case I use vim
vim ~/.zshrc
Add the following line for the path.
export ANDROID_HOME="/Users/<yourcomputername>/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Make sure to add the above line correctly else it will give you a weird error.
Save the changes and close the editor.
Finally, now compile your changes
source ~/.zshrc
I get this working in my case. I hope this helps you.

I solved this error with installing adb
On Linux
sudo apt-get install android-tools-adb

First I have setup the path in .bash_profile like this
export PATH="~/Library/Android/sdk/platform-tools":$PATH
export ANDROID_HOME="~/Library/Android/sdk/platform-tools"
But it does not resolve my problem.
For me by adding following npm script in package.json under script tag worked like charm on Mac.
"android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
Then I am simply running npm run android-dev and it's all set. Make sure that in your app setting Live reload is enabled already, in this way I can worked on development server on my mobile and see the coding changes immediately in app.

I was on Linux and in my case the ANDROID_HOME env variable was already added to the .zshrc but the path was incorrect, correcting the path fixed it.
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
add these in the ~/.zshrc file and reload your terminal.

If none of the solution works. Try running
source ~/.bash_profile&&react-native run-android
Update this in the package.json file under scripts for android as
"android": "source ~/.bash_profile&&react-native run-android"
For MacOS version Catalina and above:
"android": "source ~/.zshrc&&react-native run-android"

This worked for me,
On Linux
sudo apt-get install android-tools-adb

For Mac only
If the accepted answer doesn't work for you then check if you have "adb" installed on your system. If not, install adb using homebrew.

touch ~/.zshrc
open ~/.zshrc
add
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
save
source ~/.zshrc
run android

In my situation, I'm on Pop OS(Ubuntu) and I have android-studio installed, so I just
ln -s ~/Android/Sdk/platform-tools/adb /usr/bin/adb

Related

Unable to load script make sure you are either running a metro server react native solution [duplicate]

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync
Here is a log
JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.
* 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: 3.785 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
NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.
I found my android emulator when executing adb devices
List of devices attached
192.168.56.101:5555 device
I have tried the following steps from Stack Overflow post, but still no luck
https://stackoverflow.com/a/38536290/4540216
I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.
Follow this React-native android-setup documentation
ex:
export ANDROID_HOME=~/Library/Android/sdk
Windows:
set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk
macOS Mojave and earlier or bash users:
1 - Open your bash profile:
open .bash_profile
Add this to your bash_profile:
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.bash_profile
For macOS Catalina and zsh users:
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
On your Mac:
Open your .zshrc file:
open ~/.zshrc
If .zshrc file not exist, you need to create one using touch & open.
touch ~/.zshrc
Add this to your .zshrc file
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.zshrc
Edit: Updated answer for macOS Catalina and zsh users.
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
More details on zsh from Apple
So on your Mac:
1 - Open your .zshrc file:
open ~/.zshrc
2 - if .zshrc file doesn't exist, you need to create one & open again(Step 1)
touch ~/.zshrc
3 - Add this to your .zshrc file(Add JAVA_HOME to use Android Studio Embedded JDK)
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export ANDROID_HOME=/Users/<your_computer_name_here>/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
4 - Save and close
5 - Compile your changes
source ~/.zshrc
& make sure to restart your terminal.
I also got the same issue. And I updated my ANDROID_HOME env variable again in same cmd and it was worked fine.
> export ANDROID_HOME=~/Android/Sdk
> export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
good luck
this was my solutions
operating system: Linux mint
sudo apt-get install android-tools-adb
This answer is for MacOs Catalina or above user or zsh users as your Mac now uses zsh as the default login shell and interactive shell.
This is related to path issues.
If you follow along with the docs of React Native Setting up the development environment guide. Then do the following.
Open ~/.zshrc using editor. In my case I use vim
vim ~/.zshrc
Add the following line for the path.
export ANDROID_HOME="/Users/<yourcomputername>/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Make sure to add the above line correctly else it will give you a weird error.
Save the changes and close the editor.
Finally, now compile your changes
source ~/.zshrc
I get this working in my case. I hope this helps you.
I solved this error with installing adb
On Linux
sudo apt-get install android-tools-adb
First I have setup the path in .bash_profile like this
export PATH="~/Library/Android/sdk/platform-tools":$PATH
export ANDROID_HOME="~/Library/Android/sdk/platform-tools"
But it does not resolve my problem.
For me by adding following npm script in package.json under script tag worked like charm on Mac.
"android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
Then I am simply running npm run android-dev and it's all set. Make sure that in your app setting Live reload is enabled already, in this way I can worked on development server on my mobile and see the coding changes immediately in app.
I was on Linux and in my case the ANDROID_HOME env variable was already added to the .zshrc but the path was incorrect, correcting the path fixed it.
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
add these in the ~/.zshrc file and reload your terminal.
If none of the solution works. Try running
source ~/.bash_profile&&react-native run-android
Update this in the package.json file under scripts for android as
"android": "source ~/.bash_profile&&react-native run-android"
For MacOS version Catalina and above:
"android": "source ~/.zshrc&&react-native run-android"
This worked for me,
On Linux
sudo apt-get install android-tools-adb
For Mac only
If the accepted answer doesn't work for you then check if you have "adb" installed on your system. If not, install adb using homebrew.
touch ~/.zshrc
open ~/.zshrc
add
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
save
source ~/.zshrc
run android
In my situation, I'm on Pop OS(Ubuntu) and I have android-studio installed, so I just
ln -s ~/Android/Sdk/platform-tools/adb /usr/bin/adb

Unable to set PATH in WebStorm for Android SDK in Apache Cordova in MAC OS

I am new to Apache Cordova and making Hybrid Applications.
I have tried all the options but I am still not able to give my Android SDK Path in WebStorm (the IDE that I am using). I am using Mac Machine running on OS Mojave.
sudo export ANDROID_HOME="/Users/nabiharaza/Library/Android/sdk"
sudo export PATH="$HOME/Android/tools:$/Users/nabiharaza/Library/Android/sdk"
sudo export PATH="$HOME/Android/platform-tools:$/Users/nabiharaza/Library/Android/sdk"
I have already run these commands on the terminal.
The path where my SDK is "/Users/nabiharaza/Library/Android/sdk"
Can someone help me with fixing this issue.
when you run sudo export, you won't change anything to the shell of the current user. you have to edit ~/.bashrc (or however the current user's profile would be called on OSX; just see ls -la $HOME) and add this:
export ANDROID_HOME="/Users/nabiharaza/Library/Android/sdk"
export PATH=$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools/bin:$PATH

Could not run adb reverse: spawnSync Typo in file location? [duplicate]

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync
Here is a log
JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.
* 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: 3.785 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
NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.
I found my android emulator when executing adb devices
List of devices attached
192.168.56.101:5555 device
I have tried the following steps from Stack Overflow post, but still no luck
https://stackoverflow.com/a/38536290/4540216
I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.
Follow this React-native android-setup documentation
ex:
export ANDROID_HOME=~/Library/Android/sdk
Windows:
set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk
macOS Mojave and earlier or bash users:
1 - Open your bash profile:
open .bash_profile
Add this to your bash_profile:
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.bash_profile
For macOS Catalina and zsh users:
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
On your Mac:
Open your .zshrc file:
open ~/.zshrc
If .zshrc file not exist, you need to create one using touch & open.
touch ~/.zshrc
Add this to your .zshrc file
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.zshrc
Edit: Updated answer for macOS Catalina and zsh users.
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
More details on zsh from Apple
So on your Mac:
1 - Open your .zshrc file:
open ~/.zshrc
2 - if .zshrc file doesn't exist, you need to create one & open again(Step 1)
touch ~/.zshrc
3 - Add this to your .zshrc file(Add JAVA_HOME to use Android Studio Embedded JDK)
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export ANDROID_HOME=/Users/<your_computer_name_here>/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
4 - Save and close
5 - Compile your changes
source ~/.zshrc
& make sure to restart your terminal.
I also got the same issue. And I updated my ANDROID_HOME env variable again in same cmd and it was worked fine.
> export ANDROID_HOME=~/Android/Sdk
> export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
good luck
this was my solutions
operating system: Linux mint
sudo apt-get install android-tools-adb
This answer is for MacOs Catalina or above user or zsh users as your Mac now uses zsh as the default login shell and interactive shell.
This is related to path issues.
If you follow along with the docs of React Native Setting up the development environment guide. Then do the following.
Open ~/.zshrc using editor. In my case I use vim
vim ~/.zshrc
Add the following line for the path.
export ANDROID_HOME="/Users/<yourcomputername>/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Make sure to add the above line correctly else it will give you a weird error.
Save the changes and close the editor.
Finally, now compile your changes
source ~/.zshrc
I get this working in my case. I hope this helps you.
I solved this error with installing adb
On Linux
sudo apt-get install android-tools-adb
First I have setup the path in .bash_profile like this
export PATH="~/Library/Android/sdk/platform-tools":$PATH
export ANDROID_HOME="~/Library/Android/sdk/platform-tools"
But it does not resolve my problem.
For me by adding following npm script in package.json under script tag worked like charm on Mac.
"android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
Then I am simply running npm run android-dev and it's all set. Make sure that in your app setting Live reload is enabled already, in this way I can worked on development server on my mobile and see the coding changes immediately in app.
I was on Linux and in my case the ANDROID_HOME env variable was already added to the .zshrc but the path was incorrect, correcting the path fixed it.
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
add these in the ~/.zshrc file and reload your terminal.
If none of the solution works. Try running
source ~/.bash_profile&&react-native run-android
Update this in the package.json file under scripts for android as
"android": "source ~/.bash_profile&&react-native run-android"
For MacOS version Catalina and above:
"android": "source ~/.zshrc&&react-native run-android"
This worked for me,
On Linux
sudo apt-get install android-tools-adb
For Mac only
If the accepted answer doesn't work for you then check if you have "adb" installed on your system. If not, install adb using homebrew.
touch ~/.zshrc
open ~/.zshrc
add
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
save
source ~/.zshrc
run android
In my situation, I'm on Pop OS(Ubuntu) and I have android-studio installed, so I just
ln -s ~/Android/Sdk/platform-tools/adb /usr/bin/adb

ionic build Android | error: No installed build tools found. Please install the Android build tools

When I run ionic build android command in root of ionic project, I am getting this error:
FAILURE: Build failed with an exception.
Where: Script '/home/javad/Desktop/javadApp/platforms/android/CordovaLib/cordova.gradle'
line: 64
What went wrong: A problem occurred evaluating root project 'android'.
No installed build tools found. Please install the Android build tools version 19.1.0 or higher.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
javad#javad:~/Desktop/javadApp$ ionic build android
Running command: /home/javad/Desktop/javadApp/hooks/after_prepare/010_add_platform_class.js /home/javad/Desktop/javadApp
add to body class: platform-android
Running command: /home/javad/Desktop/javadApp/platforms/android/cordova/build
ANDROID_HOME=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/default-java
Running: /home/javad/Desktop/javadApp/platforms/android/gradlew cdvBuildDebug -b /home/javad/Desktop/javadApp/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* Where:
Script '/home/javad/Desktop/javadApp/platforms/android/CordovaLib/cordova.gradle' line: 64
* What went wrong:
A problem occurred evaluating root project 'android'.
> No installed build tools found. Please install the Android build tools version 19.1.0 or higher.
* 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: 1.564 secs
/home/javad/Desktop/javadApp/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /home/javad/Desktop/javadApp/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/javad/Desktop/javadApp/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /home/javad/Desktop/javadApp/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /home/javad/Desktop/javadApp/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
in ~/.profile i have:
export PATH=$PATH:/opt/android-sdk/tools
export PATH=$PATH:/opt/android-sdk/platform-tools
export PATH=$PATH:/opt/node/bin
export JAVA_HOME=/usr/lib/jvm/default-java
export ANDROID_HOME=/opt/android-sdk
$PATH is:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/android-sdk/tools:/opt/android-sdk/platform-tools:/opt/node/bin
Important issue:
in file:
/home/javad/Desktop/javadApp/platforms/android/CordovaLib/cordova.gradle | line 38:
String[] getAvailableBuildTools() {
def buildToolsDir = new File(getAndroidSdkDir(), "build-tools")
buildToolsDir.list()
.findAll { it ==~ /[0-9.]+/ }
.sort { a, b -> compareVersions(b, a) }
}
just returned /opt/android-sdk/build-tools !!!
in /opt/android-sdk/build-tools folder i have:
android-5.1 folder that extract from:
https://dl.google.com/android/repository/build-tools_r22-linux.zip
I fix this by downloading sdk package called platform-tools and buid-tools using sdkmanager. You can use sdkmanager.exe or if you are using SDK CLI, go to ~\AppData\Local\Android\sdk\tools\bin and run this command:
sdkmanager "platform-tools" "platforms;android-26"
or
sdkmanager "build-tools;27.0.3"
or both
After that you should be able to run ionic cordova run android or ionic build android.
Note: globalize sdkmanager command by adding ~\AppData\Local\Android\sdk\tools and ~\AppData\Local\Android\sdk\tools\bin to your environment variable.
For me running these three commands fix the issue on my Mac:
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
For ease of copying here's one-liner
export ANDROID_HOME=~/Library/Android/sdk && export PATH=${PATH}:${ANDROID_HOME}/tools && export PATH=${PATH}:${ANDROID_HOME}/platform-tools && export ANDROID_SDK_ROOT=~/Library/Android/sdk
To add Permanently
Follow these steps:
Open the .bash_profile file in your home directory (for example, /Users/your-user-name/.bash_profile) in a text editor.
Add export PATH="The above exports here" to the last line of the file, where your-dir is the directory you want to add.
Save the .bash_profile or .zshrc file.
Restart your terminal. Or run source ~/.bash_profile or source ~/.zshrc depending on your terminal settings.
Adding to bash process for different systems
You are missing android SDK tools. Please try the following:
android list sdk --all
android update sdk -u -a -t <package no.>
Where <package no.> is 1,2,3,n and
-u (--no-ui) # Headless mode
-a (--all) # Includes all packages (also obsolete ones)
-t (--filter) # Filter by package index
as the error says 'No installed build tools found'
it means that
1 : It really really really did not found build tools
2 : To make him find build tools you need to define these paths correctly
export ANDROID_HOME=/Users/vijay/Software/android-sdk-macosx
export PATH=${PATH}:/Users/vijay/Software/android-sdk-macosx/tools
export PATH=${PATH}:/Users/vijay/Software/android-sdk-macosx/platform-tools
3 : IMPORTANT IMPORTANT as soon as you set environmental variables you need to reload evnironmental variables.
//For ubuntu
$source .bashrc
//For macos
$source .bash_profile
4 : Then check in terminal
$printenv ANDROID_HOME
$printenv PATH
Note : if you did not find your changes in printenv then restart the pc and try again printenv PATH, printenv ANDROID_HOME .There is also command to reload environmental variables .
4 : then open terminal and write HALF TEXT '$and' and hit tab. On hitting tab you should see full '$android' name.this verifys all paths are correct
5 : write $android in terminal and hit enter
Please install the Android build tools version 19.1.0 or higher.
The following commands can update Android SDK on Ubuntu quickly and fix the above error:
android list sdk --all
android update sdk -u -a -t 19
android update sdk -u -a -t 20
I fix the error by changing the ANDROID_HOME to
C:\Users\Gebru\AppData\Local\Android\Sdk from wrong previous directory.
I know this doesn't look related, especially given the error message, but I fixed this by installing a newer version of the Android SDK Build tools.
2018
The "android" command is deprecated.
try
sdkmanager "build-tools;27.0.3"
This work for me, as #Fadhil said
In my case, the Enviroument Variable ANDROID_HOME was pointed to wrong (old) directory. I reallocated to correct one. In my case
ANDROID_HOME=F:\Program Files (x86)\Android\android-sdk
For me, the problem was that ANDROID_HOME was pointing to an old Android SDK path. After installing Android Studio, I had to update ~/.bash_profile accordingly for MAC (El Capitan)
export ANDROID_HOME="/Users/corneliusparkin/Library/Android/sdk"
Remember to re-start terminal or run this command after updating ~/.bash_profile
source ~/.bash_profile
FOR WINDOW: I have faced this type of issue. But after exploring it solved in my case. I am using window 10. just follow few steps below:
download Android SKD Manager for windows. https://developer.android.com/studio at the
end of this page. It is zip file. after extracting it will show tools directory.
Go to drive C:\ create new folder 'android-sdk'. copy tools folder and past in
C:\android-sdk
open command prompt as Administrator. Go to cd " c:\android-sdk\tools\bin ".
sdkmanager will be show here. type
skdmanager, it will show like this
[=======================================] 100% Computing updates...
after that type "sdkmanager platform-tools" it will create platform-tools directory
in C:\android-sdk
Now set System environment variables: right click on PC select
properties. system settings will popup. click on > Environment Variables. Environment
Variables will popup.
At this window System variables as like this. C:\android-sdk\platform-tools and
C:\android-sdk\tools\bin
run command to build tools sdkmanager "build-tools;27.0.3"
Also make sure java path is defined. I hope it will solve problem.
Type android on your command line and install "Android SDK Build-tools"
I Search this problem for days.... I hope it will be usefull
FINAL SOLUTION:
(I assume that you have installed Oracle-JDK and ANDROID)
open /etc/environment with
sudo nano /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/shoniisra/Android/Sdk/tools:/home/shoniisra/Android/Sdk/platform-tools:/home/shoniisra/Android/Sdk/build-tools:/home/shoniisra/Android/Sdk:/home/shoniisra/android-studio/bin"
JAVA_HOME="/home/shoniisra/java/jdk1.8.0_231"
ANDROID_HOME="/home/shoniisra/Android/Sdk/build-tools/29.0.2"
ANDROID_SDK_ROOT="/home/shoniisra/Android/Sdk"
ANT_HOME="/home/shoniisra/ant/apache-ant-1.9.14"
Save and exit (CTRL+o CTRL+X)
Reload file source /etc/environment
If you recently installed Android you should accept some licences
cd ~/Android/Sdk/tools/bin/
Execute sdkmanager:
./sdkmanager --licenses
Then Accept all, and Finally generate your APK
cd {yourproyect}
sudo ionic cordova build android
I have solved this issue by following steps:
Go to cordova.gradle file
(platform/android/cordovaLib/cordova.gradle)
Search for getAndroidSdkDir() method
Now simply replace System.getenv("ANDROID_HOME") with your real Android SDK path
In build.gradle script it checks if build-tools version is lower than maxVersion from Gradle configuration.
So in my case, I had environment SDK vars set, but my version was higher than allowed.
def highestBuildToolsVersion = buildToolsDirContents
.collect { new Version(it) }
// Invalid inputs will be handled as 0.0.0
.findAll { it.isHigherThan('0.0.0') && it.isLowerThan(maxVersion) }
.max()
In my case the problem was that ANDROID_HOME was pointing to ~/Library/Android/ for some reason.
The correct path is ~/Library/Android/sdk
This problem I solved with the following detail, somehow the android SDK manage installed all the dependencies and necessary files, but forget this `templates` files where is found templates> gradle> wrapper. This set of files is missing.
Path in mac
/Users/giogio/Library/Android/sdk/tools/templates
I had the same problem. I tried all the solutions on this page, but what worked for me was installing the EXACT version of build-tools requested. In my case, I had a later version installed(33.0.0), but in order to make it work I had to download an older one 30.0.3.
This works for me! be careful with the new java versions because they cause error, check that you have everything installed and in your specific directory,
I did not use openJDK
export JAVA_HOME="/usr/lib/jvm/java-8-jdk" \
&& export PATH=$JAVA_HOME/bin:$PATH \
&& export ANDROID_HOME=$HOME/Android/Sdk \
&& export PATH=${PATH}:${ANDROID_HOME}/tools \
&& export PATH=${PATH}:${ANDROID_HOME}/platform-tools \
&& export GRADLE_HOME=/usr/share/java/gradle/bin/gradle \
export PATH=$PATH:$GRADLE_HOME/bin
Linux 4.14.39-1-MANJARO #1 SMP PREEMPT Wed May 2 19:03:39 UTC 2018 x86_64 GNU/Linux
I added <preference name="android-minSdkVersion" value="19" />
to my conf.xml and the build was successful.
The solution for this question is here
https://docops.ca.com/devtest-solutions/8-0-2/en/installing/setting-up-the-mobile-testing-environment/preinstallation-steps-for-mobile-testing/
Please follow this steps, and solve your problem.
The Android SDK package contains a component called compile tools. The mobile test requires at least version 19.0.1, 19.1.0 or 20.0.0.
If these versions are not installed with your ADT package, you may receive an error message when creating a mobile asset in the DevTest Workstation:
Mac IOS
Edit ~/.bash_profile by using vi or other shell editor
vi ~/.bash_profile
Add the following lines:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:~/Software/android-sdk-macosx/tools:~/Software/android-sdk-macosx/platform-tools"
(save the file, and exit)
load those updated env variables to the current shell env:
. ~/.bash_profile
If from some reason you have an old version of the build tools, you can update them from the android development studio:
Configure --> SDK Manager --> select "Android SDK Build-Tools
Check the "Show Package details"
review the versions of this package, update if needed
Well Many people give their answer, some answer is same, some answer id different. I try many answer but they are did not work for me, of course I try from above answer also but did not solve my issue. And I don't know why but I have the same error even my issue solved by this ANSWER. I just want to write it might be helpful for someone.
I have tried all the above solution. None works.
Until I was linked to https://forum.ionicframework.com/t/ionic-v4-no-installed-build-tools-found/152150.
Apparently, you must run the command as root. Sudo is not enough. You need to change to root user before you can run all the commands.
Open Command Prompt Check for ANDROID_HOME path using SET ANDROID_HOME, if not set then set using below command.
SET ANDROID_HOME="C:\Users\VenkateshMogili\AppData\Local\Android\Sdk"
OR
open system environment variables and create new variable as
Variable Name: ANDROID_HOME
Variable Value: C:\Users\VenkateshMogili\AppData\Local\Android\Sdk
and open cordova.gradle file (/platforms/android/CordovaLib/cordova.gradle) and search for getAndroidSdkDir() method and Replace the ANDROID_HOME path ("C:/Users/VenkateshMogili/AppData/Local/Android/Sdk") instead of System.getenv("ANDROID_HOME")
If license problem arises then type below command by opening the command prompt in C:\Users\VenkateshMogili\AppData\Local\Android\Sdk\tools\bin
sdkmanager "build-tools;27.0.3" //<-that will create build-tools folder and licenses folder.
It works for me.
Warning for developers using Virtual Machines
I spent a very long time trying to resolve this issue. I tried everything in this post and many more solutions on the web. However, after many failures and going through what everyone on the web was saying I still couldn't resolve the issue on my VM - which is a Windows 10 image on VMWare Workstation.
After reviewing all the solutions and descriptions of machines/operating systems people were developing on the glaring difference in my setup was I was developing in a VM.
Solution: I pulled all my code onto the host machine (Windows 10 OS), reinstalled all the dependencies, and sure as heck it all worked out first go around. After a lot of research I found some warnings that Android Studio has some known issues around installing properly in some VMs. So if you were like me & tried all solutions (many times over) and nothing worked, but you're in a VM, you may need to consider building on your host (or other physical machine)
This issue also occur if you do an upgrade to you cordova installation.
Check if your log error has something like:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting) <-------------
ANDROID_HOME=/{path}/android-sdk-linux (DEPRECATED)
Using Android SDK: /usr/lib/android-sdk
Starting a Gradle Daemon (subsequent builds will be faster)
In such case, just change ANDROID_HOME to ANDROID_SDK_ROOT in your ~/.bashrc
or similar config file.
Where before was:
export ANDROID_HOME="/{path}/android-sdk-linux"
Now is:
export ANDROID_SDK_ROOT="/{path}/android-sdk-linux"
Don't forget source it: $ . ~/.bashrc after edition.
Check whether you have added android SDK paths to the environment file (.bash_profile). If you installed android studio with default path, then add the below lines to your environment file. In my case, I am using bash so I have updated the .bash_profile
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
I wasted a day to resolve this issue and finally I got solution
-First I removed ionic cordova platform android
-Install ionic cordova platform android#8
That's it
create a ~/.bash_profile and ~/.zshrc file.
touch ~/.bash_profile;
touch ~/.zshrc;
edit and copy/paste this in your ~/.bash_profile or ~/.zshrc file
So, go to your file manager and show all hidden files by using Cmd+Shift+. or Cmd+>
i) Edit your .zshrc file
export LANG=en_US.UTF-8
export ANDROID_HOME=/Users/bookwarm/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools/sdkmanager
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/platform-tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/build-tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools/bin
export ANDROID_NDK=/Users/{your name}/Library/Android/sdk/ndk-bundle
export JAVA_HOME=$(/usr/libexec/java_home)
ii) Edit your .bash_profile file
export ANDROID_HOME=/Users/{your name}/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools/sdkmanager
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/platform-tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/build-tools
export PATH=$PATH:/Users/{your name}/Library/Android/sdk/tools/bin
export ANDROID_NDK=/Users/{your name}/Library/Android/sdk/ndk-bundle
export JAVA_HOME=$(/usr/libexec/java_home)
Save your file with file->save like you would save any regular file, after that write this in your terminal
source ~/.bash_profile;
source ~/.zshrc;
Close you terminal and run your command now

Not able to access adb in OS X through Terminal, "command not found"

I have installed Android SDK and Eclipse on my Mac system. I am able to program using Eclipse and have created few sample applications. But I am still not able to access adb through the terminal window. I have tried following command in terminal:
$ pwd
/Users/espireinfolabs/Desktop/soft/android-sdk-mac_x86/platform-tools
$ ls
NOTICE.txt dexdump llvm-rs-cc-2
aapt dx llvm-rs-cc.txt
adb lib source.properties
aidl llvm-rs-cc
$ adb --help
-bash: adb: command not found
I have also added the ls output so that you know in which window I am.
The problem is: adb is not in your PATH. This is where the shell looks for executables. You can check your current PATH with echo $PATH.
Bash will first try to look for a binary called adb in your Path, and not in the current directory. Therefore, if you are currently in the platform-tools directory, just call
./adb --help
The dot is your current directory, and this tells Bash to use adb from there.
But actually, you should add platform-tools to your PATH, as well as some other tools that the Android SDK comes with. This is how you do it:
Find out where you installed the Android SDK. This might be (where $HOME is your user's home directory) one of the following (or verify via Configure > SDK Manager in the Android Studio startup screen):
Linux: $HOME/Android/Sdk
macOS: $HOME/Library/Android/sdk
Find out which shell profile to edit, depending on which file is used:
Linux: typically $HOME/.bashrc
macOS: typically $HOME/.bash_profile
With Zsh: $HOME/.zshrc
Open the shell profile from step two, and at the bottom of the file, add the following lines. Make sure to replace the path with the one where you installed platform-tools if it differs:
export ANDROID_HOME="$HOME/Android/Sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
Save the profile file, then, re-start the terminal or run source ~/.bashrc (or whatever you just modified).
Note that setting ANDROID_HOME is required for some third party frameworks, so it does not hurt to add it.
For zsh users. Add alias adb='/Users/$USER/Library/Android/sdk/platform-tools/adb' to .zshrc file.
Then run source ~/.zshrc command
run command in terminal nano $HOME/.zshrc
Must include next lines:
export PATH=$PATH:~/Library/Android/sdk/platform-tools
export ANDROID_HOME=~/Library/Android/sdk
export PATH="$HOME/.bin:$PATH"
export PATH="~/Library/Android/sdk/platform-tools":$PATH
Press Ctrl + X to save file in editor,Enter Yes or No and hit Enter key
Run source ~/.zshrc
Check adb in terminal, run adb
In addition to slhck, this is what worked for me (mac).
To check where your sdk is located.
Open Android studio and go to:
File -> Project Structure -> Sdk location
Copy the path.
Create the hidden .bash_profile in your home.
(open it with vim, or open -e) with the following:
export PATH=/Users/<Your session name>/Library/Android/sdk/platform-tools:/Users/<Your session name>/Library/Android/sdk/tools:$PATH
Then simply use this in your terminal: . ~/.bash_profile
SO post on how to find adb devices
Quick Answer
Pasting this command in terminal solves the issue in most cases:
** For Current Terminal Session:
(in macOS) export PATH="~/Library/Android/sdk/platform-tools":$PATH
(in Windows) i will update asap
** Permanently:
(in macOS) edit the ~/.bash_profile using vi ~/.bash_profile and add this line to it: export PATH="~/Library/Android/sdk/platform-tools":$PATH
However, if not, continue reading.
Detailed Answer
Android Debug Bridge, or adb for short, is usually located in Platform Tools and comes with
Android SDK, You simply need to add its location to system path. So system knows about it, and can use it if necessary.
Find ADB's Location
Path to this folder varies by installation scenario, but common ones are:
If you have installed Android Studio, path to ADB would be: (Most Common)
(in macOS) ~/Library/Android/sdk/platform-tools
(in Windows) i will update asap
If you have installed Android Studio somewhere else, determine its location by going to:
(in macOS) Android Studio > Preferences > Appearance And Behavior > System Settings > Android SDK and pay attention to the box that says: Android SDK Location
(in Windows) i will update asap
However Android SDK could be Installed without Android studio, in this case your path might be different, and depends on your installation.
Add it to System Path
When you have determined ADB's location, add it to system, follow this syntax and type it in terminal:
(in macOS)
export PATH="your/path/to/adb/here":$PATH
for example: export PATH="~/Library/Android/sdk/platform-tools":$PATH
I don't know how did you install the android SDK. But in Mac OS, what really worked for me is to reinstall it using brew. All problems solved in a row.
brew install --cask android-sdk
Later on:
android update sdk --no-ui --filter 'platform-tools'
Like a charm
This is how it worked for me
first I find my platform-tools than I was using zshrc instead of bash_profile so I run this command first
echo 'export PATH=${PATH}:$HOME/Library/Android/sdk/platform-tools/' >> ~/.zshrc
next refresh terminal
source ~/.zshrc
Check if it worked
adb devices
result of this command must be something similar to this if so then it worked.
List of devices attached
emulator-5554 device
For me, I ran into this issue after switching over from bash to zsh so I could get my console to look all awesome fantastic-ish with Hyper and the snazzy theme. I was trying to run my react-native application using react-native run-android and running into the op's issue. Adding the following into my ~.zshrc file solved the issue for me:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
If you have installed Android Studio on MAC here is how:
nano ~/.zshrc
or
open ~/.zshrc in VScode
Then edit the file
# Android ADB
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
control + X OR Save file.
Restart Terminal and try
> adb
UPDATE
As #Loren.A mentioned in comment latest version of brew does not support cast. So one can simply use:
brew install android-platform-tools
Simply install adb with brew
brew cask install android-platform-tools
Check if adb is installed
adb devices
If you are using the Mac with the M1 chip add the below export command to the zshrc file using the nano command, if that file is not present the nano command will create it for you so run
nano ~/.zshrc
paste this path in that file without any modification
export PATH="/Users/$USER/Library/Android/sdk/platform-tools":$PATH
hit ctrl-x and then Hit y to save the changes and the hit return Key to close it without renaming the file.
then run
source ~/.zshrc
to refresh the .zshrc file
and then try runnning
adb
it should give you the desired output
If you are using zsh on an OS X, you have to edit the zshrc file.
Use vim or your favorite text editor to open zshrc file:
vim ~/.zshrc
Paste the path to adb in this file:
export PATH="/Users/{$USER}/Library/Android/sdk/platform-tools":$PATH
For Mac OS Catalina or Mojave
Enter command to open nano editor
nano $HOME/.zshrc
Set PATH variable, means append more path as shown here
FLUTTER_HOME="/Users/pankaj/Library/Android/flutter-sdk/flutter/bin"
DART_HOME="/Users/pankaj/Library/Android/flutter-sdk/flutter/bin/cache/dart-sdk/bin"
ANDROID_SDK_HOME="/Users/pankaj/Library/Android/sdk"
ANDROID_ADB_HOME="/Users/pankaj/Library/Android/sdk/platform-tools"
PATH="$PATH:$FLUTTER_HOME"
PATH="$PATH:$DART_HOME"
PATH="$PATH:$ANDROID_SDK_HOME"
PATH="$PATH:$ANDROID_ADB_HOME"
Now press Command + X to save file in editor,Enter Yes or No and hit Enter key.
This worked for me on my MAC - 2020
Go to directory containing adb:
cd ~/Library/Android/sdk/platform-tools/
Run adb command to list all services
./adb shell dumpsys activity services
I couldn't get the stupid path working so I created an alias for abd
alias abd ="~/Library/Android/sdk/platform-tools/adb"
works fine.
For Mac, Android Studio 3.6.1, I added this to .bash_profile
export PATH="~/Library/Android/sdk/platform-tools/platform-tools":$PATH
Or the alternative solution could be
Make sure you already install for android SDK. Usually it is located under
/Users/your-user-name/Library/Android/sdk
If the SDK is there then run this command. ./platform-tools/adb install your-apk-location
From there you can generate the APK file That's the only sample to check if adb
command is there
For some reason when installed Android Studio 3.6.1 the adb file was actually in $ANDROID_HOME/platform-tools/platform-tools. not sure if this is a bug with my installation or what but this fixed it for me.
For Mac Os the default shell has moved on to "zsh" from "bash" as of Mojave and later releases, so for all the Mac users I would suggest go with the creating ".zshrc" file. "adb" runs as it is intended to be. Thanks #slhck for your info.!
Follow steps below
Open bash_profile using open -e .bash_profile
write
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
close bash_profile file
run source .bash_profile
Done run your adb command now !!
In some cases, you may need to run source .bash_profile every time you open cmd to run adb commands
It's working fine..
brew install android-sdk
Later on:
android update sdk --no-ui --filter 'platform-tools'

Categories

Resources