Related
I'm trying to build an Alpine image containing the Android SDK - specifically, the platform-tools package.
My Dockerfile does the following:
Installs Java and sets JAVA_HOME (needed for Android).
Downloads the Android SDK tools from Google.
Unzips the package.
Sets ANDROID_HOME. Also sets PATH so the sdkmanager executable can be used.
Installs platform-tools using sdkmanager.
Adds platform-tools to PATH.
platform-tools contains an executable named adb, but for some reason it cannot be seen. Running adb returns:
bash: /android-sdk/platform-tools/adb: No such file or directory
Here is my Dockerfile:
FROM alpine:latest
# Install bash and java
RUN apk update
RUN apk add bash openjdk8
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH="$PATH:$JAVA_HOME/bin"
# Download Android SDK and set PATH
RUN mkdir /android-sdk
RUN wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && unzip *.zip -d /android-sdk && rm *.zip
ENV ANDROID_HOME="/android-sdk"
ENV PATH="$PATH:$ANDROID_HOME/tools/bin"
# Install platform-tools
RUN yes | sdkmanager "platform-tools"
ENV PATH="$PATH:$ANDROID_HOME/platform-tools"
RUN adb version # throws error: adb not found
I've looked at this question but the problem should be fixed with platform-tools v24.0 and higher.
Alpine uses musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements.
adb is compiled with glibc, so it won't be able to run in Alpine, which usually results in the error: No such file or directory.
You can verify that a file is compiled with glibc by running file <path to file> | grep "interpreter /lib64/ld-linux-x86-64.so.2".
This may help, although the Gradle daemon randomly crashes for me on Alpine Linux when using the compatibility layer.
gcompat is the go-to compatibility layer for Alpine users.
apk add gcompat
After that you run your binaries as normal.
Source: https://wiki.alpinelinux.org/wiki/Running_glibc_programs
You can install android-tools like so:
RUN apk add \
android-tools \
--repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
The key is to set the --repository as shown, as it's only in the edge testing repo.
I don't think it includes the whole SDK, so may need to download and unzip as well for other tools. I don't know if this will handle everything you want, but adb prints a help document at least.
I spent quite sometime figuring how to set up adb on Mac, so I figure writing how to set it up might be useful to some people. adb is the command line tool to install and run android apps on your phone/emulator
Note: this was originally written on Installing ADB on macOS but that question was closed as a duplicate of this one.
Note for zsh users: replace all references to ~/.bash_profile with ~/.zshrc.
Option 1 - Using Homebrew
This is the easiest way and will provide automatic updates.
Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install adb
brew install android-platform-tools
or try a cask install depending on your settings:
brew install --cask android-platform-tools
Start using adb
adb devices
Option 2 - Manually (just the platform tools)
This is the easiest way to get a manual installation of ADB and Fastboot.
Delete your old installation (optional)
rm -rf ~/.android-sdk-macosx/
Navigate to https://developer.android.com/studio/releases/platform-tools.html and click on the SDK Platform-Tools for Mac link.
Go to your Downloads folder
cd ~/Downloads/
Unzip the tools you downloaded
unzip platform-tools-latest*.zip
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv platform-tools/ ~/.android-sdk-macosx/platform-tools
Add platform-tools to your path
echo 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
Option 3 - If you already have Android Studio installed
Add platform-tools to your path
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
Option 4 - MacPorts
Install the Android SDK:
sudo port install android
Run the SDK manager:
sh /opt/local/share/java/android-sdk-macosx/tools/android
Uncheck everything but Android SDK Platform-tools (optional)
Install the packages, accepting licenses. Close the SDK Manager.
Add platform-tools to your path; in MacPorts, they're in /opt/local/share/java/android-sdk-macosx/platform-tools. E.g., for bash:
echo 'export PATH="$PATH:/opt/local/share/java/android-sdk-macosx/platform-tools"' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal/shell):
source ~/.bash_profile
Start using adb:
adb devices
Option 5 - Manually (with SDK Manager)
Delete your old installation (optional)
rm -rf ~/.android-sdk-macosx/
Download the Mac SDK Tools from the Android developer site under "Get just the command line tools". Make sure you save them to your Downloads folder.
Go to your Downloads folder
cd ~/Downloads/
Unzip the tools you downloaded
unzip tools_r*-macosx.zip
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv tools/ ~/.android-sdk-macosx/tools
Run the SDK Manager
sh ~/.android-sdk-macosx/tools/android
Uncheck everything but Android SDK Platform-tools (optional)
Click Install Packages, accept licenses, click Install. Close the SDK Manager window.
Add platform-tools to your path
echo 'export PATH="$PATH:~/.android-sdk-macosx/platform-tools/"' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile && source ~/.bash_profile
If you put the android-sdks folder in other directory, replace the path with the directory android-sdks/platform-tools is in
Only for zsh users in iterm2 in macOS
type the following two commands to add the android sdk and platform-tools to your zsh in iterm2 in macOS
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.zshrc
After adding the two command to ~/.zshrc you need to source the zsh.
source ~/.zshrc
This Works Flawless....
In terminal Run both commands next to each other
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
NOTE: Path for adb has changed since Android Studio 1.0.xx
For bash shell, use:
echo 'export PATH=$PATH:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.bash_profile
For tcsh shell, use:
echo 'setenv PATH $PATH\:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.tcshrc
2022 Solution
If you have Android Studio installed already and Terminal isn't picking up ADB, here's a one-liner that should fix it:
sudo ln -s ~/Library/Android/sdk/platform-tools/adb /usr/local/bin
If you are using zsh shell and after trying all this solutions, you still need to set $PATH and $ANDROID_HOME every time you open new terminal instance, then here is your answer:
step 1: in terminal run nano ~/.zshrc
step 2: paste following command at the end of the file
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
step 3: After copying the lines above, to save hit control + X. and to confirm hit Y. It will ask you if you wish to change the file name but don't change the name so directly hit enter
step 4: Restart your terminal and execute the adb command.
Bingo!
Here is a step wise information :
Step-1
Start up Terminal and go to your home folder.
cd ~/
Step-2
Open and edit .bash_profile file
$ open -e .bash_profile
If you don’t have .bash_profile file in your computer path, then create one. Enter below command to create a new file. Once created follow Step-2.
touch .bash_profile
Step-3
Save the below line)
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools
Step-4
Refresh the file using below command
$ source .bash_profile
$ echo $PATH
You should see your android path set in the output now.
Personally I just source my .bashrc in my .bash_profile:
echo 'source ~/.bashrc' >> ~/.bash_profile
So I put it in my .bashrc. And I'm using Android Studio, so it was a different path.
echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.bashrc
You may also want the following:
echo 'ANDROID_HOME=$HOME/Library/Android/sdk' >> ~/.bashrc
The simplest way to use adb command on your Mac systems would be to add the path to the platform-tools (where adb lives) into your bash_profile.
Steps to add the adb path:
1. open the bash_profile: This can be done by using the following commands
open ~/.bash_profile
This opens up the bash_profile in an editor.
Locate the platform_tools, usually they are present at the following location: Users/"user_folder"/Library/Android/sdk/platform_tools
Paste the following command in the bash_profile file which opens up:
export PATH=$PATH:/Users/A374375/Library/Android/sdk/platform-tools
Save the file using the command:
source ~/.bash_profile
Check if the path is saved by typing: echo $PATH : You should be able to find the entire path displayed in the output.
Type adb to see if the configuration worked. If you have any devices connected to the machine or any emulators running on your system they would be displayed when you type adb devices
output for adb devices
For Mac users :
Step 1: Install the Android Studio
Step2 : Open the terminal and type
cd
Step 3: Type below mentioned command changing the userName:
export PATH=“/Users/{user_name}/Library/Android/sdk/platform-tools”:$PATH
cd sdk/platform-tools/ and then use ./adb devices instead
On MacOS Big Sur do the following:
Open config file:
nano ~/.zshrc
Add paths to PATH variable:
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH
close file and save changes.
Then in terminal write:
source ~/.zshrc
And then you'll be able to run:
adb devices
adb kill-server
If you using zsh then you need do the add the following to your .zshrc
Steps:
Step 1: Open your .zshrc profile
open -e .zshrc
Step 2: Add the following to the file
export PATH=$PATH:/Users/${YourUser}/Library/Android/sdk/platform-tools
export ANDROID_HOME=/Users/${YourUser}/Library/Android/sdk
Step 3: Save the file and close.
Step 4: Reload the .zshrc
source .zshrc
Step 5: Check the devices connected
adb devices
MAC Solution.
cd /Users/<user>/Library/Android/sdk/platform-tools
./adb devices
if you are using Android Studio in MAC OS X , you could exec the following command in your terminal app:
echo 'alias adb="/Applications/Android\ Studio.app/sdk/platform-tools/adb"' >> .bashrc
exec $SHELL
and next:
adb devices
and you should be showing a list with your android devices connected via USB cable in your MAC, for example something like this:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
deb7bed5 device
For macOS Users Updated to MacOs Catalina,
~/.bash_profile changed to ~/.zshrc
So ,to run adb command and all other commands already exported to ~/.bash_profile easy walkaround is to export bash_profile to zshrc
To do that,
1) Navigate to the home directory in finder
2) I used Cmd + Shift + . to show the hidden files in Finder
3) Create .zshrc file if already not exist
4) Add line "source ~/.bash_profile" without quotes
5) Save
6) Quit and open terminal
start using adb devices
Here's a detailed manual:
http://codexpi.com/add-android-adb-path-mac-os-x-mavericks/
To sum this up:
Create and open the bash_profile file
touch .bash_profile
open -e .bash_profile
Add the path of the platform-tools folder (within the Android SDK)
export PATH="$PATH:/Users/USERNAME/PATH TO ANDROID SDK/platform-tools/
Run the command . .bash_profile to update (no need to restart the terminal)
If you are using ZSH and have Android Studio 1.3:
1. Open .zshrc file (Located in your home directory, file is hidden so make sure you can see hidden files)
2. Add this line at the end: alias adb="/Users/kamil/Library/Android/sdk/platform-tools/adb"
3. Quit terminal
4. Open terminal and type in adb devices
5. If it worked it will give you list of all connected devices
Mac OS
Open Terminal
touch ~/.bash_profile; open ~/.bash_profile
Copy and paste:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
command + S for save.
If you are setting the path in Catalina use below command one after another in the terminal. It's working fine for me.
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
source ~/.bash_profile
Commenting with some updated information from 2018.
Executable Binaries for Platform tools are made available for mac by Android here: https://developer.android.com/studio/releases/platform-tools.html
Download these to your mac. Place them in a directory e.g. I placed in ~/Software/platform-tools
If you have root access, the easiest way I have found on a mac is to add your directories to the list in /etc/paths. I like this way because after a few additions the $PATH starts to look too messy and hard to read, the /etc/pathshas everything in separate line, clean and organized. The downside is that you require root access.
$ cat /etc/paths # check contents of the file
$ sudo nano /etc/paths
Paste the full path of your platform-tools directory (something like /Users/GodZilla/Software/platform-tools/adb) at the end of this list and save. Quit and Open terminal again and check if it sees your platform-tools directory.
$ which adb
/Users/GodZilla/Software/platform-tools/adb
$ which fastboot
/Users/GodZilla/Software/platform-tools/fastboot
If you don't have root access, just add the platform-tools directory to $PATH in your .bash_profile (or .zshenv if you use zsh) as other users have suggested.
Download Android Platform Tools for macOS from:
https://developer.android.com/studio/releases/platform-tools
Extract to your somewhere e.g ~/installs/platform-tools
Add that folder to path by running:
echo 'export PATH=$PATH:~/installs/platform-tools' >> ~/.zshrc
Either restart terminal or run:
source ~/.zshrc
Assuming that you are using zsh.
This totally worked for me, after dickering around for a while after installing Android Studio:
Make sure you have the .bash_profile file. This should be in your [username] directory.
From whatever directory you are on, type this:
echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile
Now, usually you will have this exact path, but if not, then use whatever path you have the platform-tools folder
From the directory where your .bash_profile resides, type this:
. .bash_profile
Now type adb devices. You should see a "List of devices attached" response. Now you do not have to go to the platform-tools directory each and every time to type in the more cryptic command like, ./adb devices!!!
In my case, I installed Android studio, and have some apps (rust lang) that changes the ~/.profile, and adding adb to ~/.bash_profile made the rust un-executable, so I made the changes to the ~/.profile only, as:
$ echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.profile
$ source ~/.profile
$ adb --version
Android Debug Bridge version 1.0.41
Version 29.0.4-5871666
Installed as /Users/hasan/Library/Android/sdk/platform-tools/adb
In my case : I did the following (on a mac) :
backed up the ".bash_profile" and ".profile"
cleared all the android related paths.
created the new paths but this time around, I dragged the respective folders : { /.../sdk, /.../tools, /.../platform-tools } into the terminal. I did this for both ".bash_profile" and ".profile".
Then after successfully saving the files each. I restarted the terminal just to be sure about the modifications I made.
I then went on to test if adb was responding now ...
by typing : (in terminal) adb devices
I still had no luck (my devices) where not showing, then I restarted the adb, still.
I went on to do "android update adb" . This just killed and restarted the adb
I tried again still the devices wasnt showing.
I totally backed up my android device and resetted the whole phone back to factory default, went over to activate the device for development and allow for usb debugging in its settings > applications.
******** WORKED LIKE A CHARM ********
I tried again with the command "adb devices" and everything was back to normal the device was visible.
All the best. Just dont give up. It took me a lot of troubleshooting. All the best of luck.
Considering you have already downloaded SDK platform tools.
This command will set ADB locally. So if you close the terminal and open it again, ADB commands won't work until you run this command again.
export PATH=~/Library/Android/sdk/platform-tools:$PATH
These commands will set ADB globally. So once you run these commands no need to set them again next time.
echo 'export PATH=$PATH:~/Library/Android/sdk/platform-tools/' >> ~/.bash_profile
source ~/.bash_profile
If you are using zsh terminal do the following:
1) Open .zprofile file with the editor of your choice like "open -a xcode ~/.zprofile"
2) Add new PATH or Env Variable in .zprofile Save the file and quit the editor.
3) Execute your .zprofile to update your PATH: source ~/.zprofile
Add environment variable for Android Home Targetting Platform Tools
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
Restart Bash
source ~/.bash_profile
Now Check adb
Simply type
adb
on terminal
After trying all the solutions, none of them where working for me.
In my case I had the Android Studio and the adb was correctly working but the Android Studio was not capable to detect the adb. These was because I installed it with homebrew in another directory, not the /Users/$USER/Library/Android/sdk but Usr/Library blabla
Apparently AS needed to have it in his route /Users/$USER/Library/Android/sdk (same place as in preferences SDK installation route)
So I deleted all the adb from my computer (I installed several) and executed these terminal commands:
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
source ~/.bash_profile
adb devices
Well, after that, still wasn't working, because for some reason the route for the adb was /Users/$USER/Library/Android/sdk/platform-tools/platform-tools (yes, repeated) so I just copied the last platform-tools into the first directory with all the license files and started working.
Weird but true
i have follow the instructions.phonegab docs and How to add android to cordova platform? PATH error?
my .bash_profile:
export PATH=/usr/local/bin:$PATH
export PATH=$PATH:~/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools
export PATH=${PATH}:~/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:~/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
eval "$(rbenv init -)"
but still Error while i executing cordova platform add android or ionic platform android:
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
Any Solutions? thank you
Try to run android in command line. if the command is not found, it's mean that the path of android sdk that registered is still wrong
AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
You have to manually reload your setting like for Ubuntu I am using this command "$ source ~/.bashrc"
Thank you All for your clue of solutions. I try add $HOME because /Development directory in /Home directory and i followed code RVM in my .bash_profile:
`[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
eval "$(rbenv init -)"`
The solutions in How to add android to cordova platform? PATH error? i followed symbol ~ for initialize /Development directory in /Home directory, but it's not working. and I try follow code RVM in my .bash_profile use $HOME.
this is my .bash_profile:
export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
eval "$(rbenv init -)"
and then run command source ~/.bash_profile. Solved
I want to build an Android Studio app (the Gradle build system), but I want to do this via the command line.
Android Studio automatically creates a Gradle wrapper in the root of your project, which is how it invokes Gradle. The wrapper is basically a script that calls through to the actual Gradle binary and allows you to keep Gradle up to date, which makes using version control easier. To run a Gradle command, you can simply use the gradlew script found in the root of your project (or gradlew.bat on Windows) followed by the name of the task you want to run. For instance, to build a debug version of your Android application, you can run ./gradlew assembleDebug from the root of your repository. In a default project setup, the resulting apk can then be found in app/build/outputs/apk/app-debug.apk. On a *nix machine, you can also just run find . -name '*.apk' to find it, if it's not there.
there are two build types to build your application using the Gradle build settings: one for debugging your application — debug — and one for building your final package for release — release mode.
Building in Debug Mode
First Navigate to Android studio project Root folder using CMD
run this command gradlew.bat assembleDebug
Output window look like this
Build signed apk in Release Mode
Edit the build.gradle file to build your project in release mode:
android {
...
defaultConfig { ... }
signingConfigs {
release {
storeFile file("myreleasekey.keystore")
storePassword "password"
keyAlias "MyReleaseKey"
keyPassword "password"
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}}
run this command gradlew.bat assembleRelease
Try this (OS X only):
brew install homebrew/versions/gradle110
gradle build
You can use gradle tasks to see all tasks available for the current project. No Android Studio is needed here.
1. Install Gradle and the Android SDK
Either
Install these however you see fit
Run ./gradlew, or gradlew.bat if on Windows
chmod +x ./gradlew may be necessary
From this point onwards, gradle refers to running Gradle whichever way you've chosen.
Substitute accordingly.
2. Setup the Android SDK
If you've manually installed the SDK
export ANDROID_HOME=<install location>
You may want to put that in your ~/.profile if it's not done automatically
Accept the licenses: yes | sdkmanager --licenses
sdkmanager can be found in $ANDROID_HOME/tools/bin
sdkmanager may have to be run as root
Try running gradle
If there are complaints about licenses or SDKs not being found, fix the
directory permissions
chown -R user:group $ANDROID_HOME
If you're reckless and/or the only user: chmod 777 -R $ANDROID_HOME
3. Building
gradle tasks lists all tasks that can be run
:app:[appname] is the prefix of all tasks, which you'll see in the Gradle
logs when you're building
This can be excluded when running a task
Some essential tasks
gradle assemble: build all variants of your app
Resulting .apks are in app/[appname]/build/outputs/apk/[debug/release]
gradle assembleDebug or assembleRelease: build just the debug or release versions
gradle installDebug or installRelease build and install to an attached device
Have adb installed
Attach a device with USB debugging and USB file transfer enabled
Run adb devices, check that your device is listed and device is
beside it
Automatically build and install upon changes
This avoids having to continuously run the same commands
gradle -t --continue installDebug
-t: aka --continuous, automatically re-runs the task after a file is changed
--continue: Continue after errors. Prevents stopping when errors occur
Run gradle -h for more help
You're likely here because you want to install it too!
Build
gradlew
(On Windows gradlew.bat)
Then Install
adb install -r exampleApp.apk
(The -r makes it replace the existing copy, add an -s if installing on an emulator)
Bonus
I set up an alias in my ~/.bash_profile, to make it a 2char command.
alias bi="gradlew && adb install -r exampleApp.apk"
(Short for Build and Install)
Cheatsheet for running Gradle from the command line for Android Studio projects on Linux:
cd <project-root>
./gradlew
./gradlew tasks
./gradlew --help
Should get you started..
I faced the same problem and seems that there have been many changes by google.
I can tell you the steps for installing purely via command line from scratch.
I tested it on Ubuntu on 22 Feb 2021.
create sdk folder
export ANDROID_SDK_ROOT=/usr/lib/android-sdk
sudo mkdir -p $ANDROID_SDK_ROOT
install openjdk
sudo apt-get install openjdk-8-jdk
download android sdk
Go to https://developer.android.com/studio/index.html
Then down to Command line tools only
Click on Linux link, accept the agreement and instead of downloading right click and copy link address
cd $ANDROID_SDK_ROOT
sudo wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip
sudo unzip commandlinetools-linux-6858069_latest.zip
move folders
Rename the unpacked directory from cmdline-tools to tools,
and place it under $ANDROID_SDK_ROOT/cmdline-tools,
so now it should look like: $ANDROID_SDK_ROOT/cmdline-tools/tools.
And inside it, you should have: NOTICE.txt bin lib source.properties.
set path
PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin
This had no effect for me, hence the next step
browse to sdkmanager
cd $ANDROID_SDK_ROOT/cmdline-tools/tools/bin
accept licenses
yes | sudo sdkmanager --licenses
create build
Finally, run this inside your project
chmod 777 gradlew
sudo ./gradlew assembleDebug
This creates an APK named -debug.apk at //build/outputs/apk/debug
The file is already signed with the debug key and aligned with zipalign,
so you can immediately install it on a device.
FINAL STEPS
Here are the final steps. Make 2 .sh files with these contents. Use chmod 777 before on both. No sudo required.
Download_APK_Code_NOSUDO4.sh
# Don't forget to do chmod 777 Download_APK_Code_NOSUDO2.sh
#!/bin/bash
if [ -d "camera-samples" ]; then
echo "############################# Deleting older code base. ######################################"
rm -rf camera-samples
fi
echo "########################### Download Source Code: Start ... #####################################"
git clone git://git.quicinc.com/camera-samples -b iot-concam-apk.lnx.1.1
echo "########################## Download Source Code: Done . . . ####################################"
Build_App_NOSUDO4.sh
# Don't forget to do chmod 777 Build_App_NOSUDO2.sh
#!/bin/bash
currentDir=$(pwd)
export ANDROID_SDK_ROOT=$(pwd)
# echo "############################################ Install JDK ... ################################################"
# apt-get install openjdk-8-jdk
if [ -e "commandlinetools-linux-6858069_latest.zip" ]; then
echo "############################# Deleting older zip file. ######################################"
rm -rf commandlinetools-linux-6858069_latest.zip
fi
echo "########################################### Download Command Line Tools .. ###################################"
wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip
echo "########################################### Download Command Line Tools Done .. ##############################"
if [ -d "cmdline-tools" ]; then
echo "############################# Deleting older cmdline-tools. ######################################"
rm -rf cmdline-tools
fi
echo "########################################### Unzip Command Line Tools Start .. #################################"
unzip commandlinetools-linux-6858069_latest.zip
echo "########################################### Unzip Command Line Tools Done .. #################################"
echo "########################################### Creating Directory Structure .. #################################"
mv cmdline-tools tools
mkdir cmdline-tools
cp -r tools cmdline-tools/
rm -rf tools/
PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin
echo "########################################## Updated Path : $PATH ###############################################"
cd $ANDROID_SDK_ROOT/cmdline-tools/tools/bin
echo "########################################## Accept All Licenses .. #############################################"
yes | sdkmanager --licenses
cd $currentDir/camera-samples/Camera2Video
echo "sdk.dir = $ANDROID_SDK_ROOT" > local.properties
echo "######################################## Building APK . . . #################################################"
chmod 777 gradlew
./gradlew assembleDebug
echo "####################################### Building APK Done. . . ############################################"
echo "##################################### APK generated here: $currentDir/app/build/outputs/apk/debug/app-debug.apk ###################################"
##########################################################
Run these commands.
chmod 777 Download_APK_Code_NOSUDO4.sh
chmod 777 Build_App_NOSUDO4.sh
./Download_APK_Code_NOSUDO4.sh
./Build_App_NOSUDO4.sh
REFERENCES
https://gist.github.com/guipmourao/3e7edc951b043f6de30ca15a5cc2be40
Android Command line tools sdkmanager always shows: Warning: Could not create settings
"Failed to install the following Android SDK packages as some licences have not been accepted" error
https://developer.android.com/studio/build/building-cmdline#sign_cmdline
///////////////////////////////////
WINDOWS
Here are the steps for Windows via Powershell. Tested on 6th March 2021. You can start completely from scratch.
Prerequisites
Download git
Install JDK. I used jdk-8u281-windows-x64.exe
Make a file DownloadAndBuild.ps1 with these contents.
$location = Get-Location
if (Test-Path "$location\camera-samples") {
Write-Host "########################### Deleting older code base: Start. ################################"
Remove-Item -Force -Recurse -Path "$location\camera-samples"
Write-Host "########################### Deleting older code base: Done. #################################"
}
Write-Host "########################## Download Source Code: Start. #####################################"
git clone https://source.codeaurora.org/quic/la/camera-samples -b iot-concam-apk.lnx.1.1
Write-Host "########################## Download Source Code: Done. ####################################"
if (Test-Path "$location\commandlinetools-win-6858069_latest.zip") {
Write-Host "########################### Deleting older zip file: Start. ################################"
Remove-Item -Force -Recurse -Path "$location\commandlinetools-win-6858069_latest.zip"
Write-Host "########################### Deleting older zip file: Done. #################################"
}
Write-Host "########################## Download Command Line Tools: Start. #####################################"
$client = new-object System.Net.WebClient
$client.DownloadFile("https://dl.google.com/android/repository/commandlinetools-win-6858069_latest.zip","commandlinetools-win-6858069_latest.zip")
Write-Host "########################## Download Command Line Tools: End. #####################################"
if (Test-Path "$location\cmdline-tools") {
Write-Host "########################### Deleting older folder: Start. ################################"
Remove-Item -Force -Recurse -Path "$location\cmdline-tools"
Write-Host "########################### Deleting older folder: Done. #################################"
}
Write-Host "########################## Extract Command Line Tools: Start. #####################################"
Expand-Archive "$location\commandlinetools-win-6858069_latest.zip" -DestinationPath "$location"
Write-Host "########################## Extract Command Line Tools: End. #####################################"
Write-Host "########################## Create Directory Structure: Start. #####################################"
Rename-Item -Path "$location\cmdline-tools" -newName "$location\tools"
New-Item -ItemType Directory -Force -Path "$location\cmdline-tools"
Move-Item -Path "$location\tools" -Destination "$location\cmdline-tools"
Write-Host "########################## Create Directory Structure: End. #####################################"
Write-Host "########################## Accept Licenses: Start. #####################################"
Set-Location -Path $location/cmdline-tools/tools/bin
for($i=0;$i -lt 100;$i++) { $response += "y`n"}; $response | ./sdkmanager.bat --licenses
Write-Host "########################## Accept Licenses: End. #####################################"
Write-Host "########################## Build APK: Start. #####################################"
Set-Location -Path $location/camera-samples/Camera2Video
$Env:ANDROID_SDK_ROOT = $location
.\gradlew assembleDebug
Write-Host "########################## Build APK: End. #####################################"
Write-Host "##################################### APK generated here: $location/camera-samples/Camera2Video/app/build/outputs/apk/debug/app-debug.apk ###################################"
PAUSE
Right-click and run via Powershell.
This will download an Android project via git, install the SDK and build the Android App.
Edit as per your convenience.
For Mac use this command
./gradlew task-name
MacOS variant
./gradlew <moduleName>:assemble<build_variant>
//e.g
./gradlew <moduleName>:assembleDebug
*./ means current directory
[More info]
Only for MAC Users
Extending Vji's answer.
Step by step procedure:
Open Terminal
Change your directory to your Project(cd PathOfYourProject)
Copy and paste this command and hit enter:
chmod +x gradlew
As Vji suggested:
./gradlew task-name
DON'T FORGOT TO ADD .(DOT) BEFORE /gradlew
Official Documentation is here:
To build a debug APK, open a command line and navigate to the root of your project directory. To initiate a debug build, invoke the assembleDebug task:
gradlew assembleDebug
This creates an APK named module_name-debug.apk in project_name/module_name/build/outputs/apk/.
note, you can also do this within Android Studio by clicking the gradle window, and then the 'elephant' button. This will open a new window called "run anything" (can also be found by searching for that name in 'search everywhere') where you can manually type any gradle command you want in. Not "quite" command line, but often provides more of what I need than windows command line.
This allows you to give optional params to gradle tasks, etc.
enter code hereCreate script file with below gradle and adb command, Execute script file
./gradlew clean
./gradlew assembleDebug
./gradlew installDebug
adb shell am start -n applicationID/full path of launcher activity
Adding value to all these answers,
many have asked the command for running App in AVD after build sucessful.
adb install -r {path-to-your-bild-folder}/{yourAppName}.apk
I spent quite sometime figuring how to set up adb on Mac, so I figure writing how to set it up might be useful to some people. adb is the command line tool to install and run android apps on your phone/emulator
Note: this was originally written on Installing ADB on macOS but that question was closed as a duplicate of this one.
Note for zsh users: replace all references to ~/.bash_profile with ~/.zshrc.
Option 1 - Using Homebrew
This is the easiest way and will provide automatic updates.
Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install adb
brew install android-platform-tools
or try a cask install depending on your settings:
brew install --cask android-platform-tools
Start using adb
adb devices
Option 2 - Manually (just the platform tools)
This is the easiest way to get a manual installation of ADB and Fastboot.
Delete your old installation (optional)
rm -rf ~/.android-sdk-macosx/
Navigate to https://developer.android.com/studio/releases/platform-tools.html and click on the SDK Platform-Tools for Mac link.
Go to your Downloads folder
cd ~/Downloads/
Unzip the tools you downloaded
unzip platform-tools-latest*.zip
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv platform-tools/ ~/.android-sdk-macosx/platform-tools
Add platform-tools to your path
echo 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
Option 3 - If you already have Android Studio installed
Add platform-tools to your path
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
Option 4 - MacPorts
Install the Android SDK:
sudo port install android
Run the SDK manager:
sh /opt/local/share/java/android-sdk-macosx/tools/android
Uncheck everything but Android SDK Platform-tools (optional)
Install the packages, accepting licenses. Close the SDK Manager.
Add platform-tools to your path; in MacPorts, they're in /opt/local/share/java/android-sdk-macosx/platform-tools. E.g., for bash:
echo 'export PATH="$PATH:/opt/local/share/java/android-sdk-macosx/platform-tools"' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal/shell):
source ~/.bash_profile
Start using adb:
adb devices
Option 5 - Manually (with SDK Manager)
Delete your old installation (optional)
rm -rf ~/.android-sdk-macosx/
Download the Mac SDK Tools from the Android developer site under "Get just the command line tools". Make sure you save them to your Downloads folder.
Go to your Downloads folder
cd ~/Downloads/
Unzip the tools you downloaded
unzip tools_r*-macosx.zip
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv tools/ ~/.android-sdk-macosx/tools
Run the SDK Manager
sh ~/.android-sdk-macosx/tools/android
Uncheck everything but Android SDK Platform-tools (optional)
Click Install Packages, accept licenses, click Install. Close the SDK Manager window.
Add platform-tools to your path
echo 'export PATH="$PATH:~/.android-sdk-macosx/platform-tools/"' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile && source ~/.bash_profile
If you put the android-sdks folder in other directory, replace the path with the directory android-sdks/platform-tools is in
Only for zsh users in iterm2 in macOS
type the following two commands to add the android sdk and platform-tools to your zsh in iterm2 in macOS
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.zshrc
After adding the two command to ~/.zshrc you need to source the zsh.
source ~/.zshrc
This Works Flawless....
In terminal Run both commands next to each other
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
NOTE: Path for adb has changed since Android Studio 1.0.xx
For bash shell, use:
echo 'export PATH=$PATH:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.bash_profile
For tcsh shell, use:
echo 'setenv PATH $PATH\:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.tcshrc
2022 Solution
If you have Android Studio installed already and Terminal isn't picking up ADB, here's a one-liner that should fix it:
sudo ln -s ~/Library/Android/sdk/platform-tools/adb /usr/local/bin
If you are using zsh shell and after trying all this solutions, you still need to set $PATH and $ANDROID_HOME every time you open new terminal instance, then here is your answer:
step 1: in terminal run nano ~/.zshrc
step 2: paste following command at the end of the file
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
step 3: After copying the lines above, to save hit control + X. and to confirm hit Y. It will ask you if you wish to change the file name but don't change the name so directly hit enter
step 4: Restart your terminal and execute the adb command.
Bingo!
Here is a step wise information :
Step-1
Start up Terminal and go to your home folder.
cd ~/
Step-2
Open and edit .bash_profile file
$ open -e .bash_profile
If you don’t have .bash_profile file in your computer path, then create one. Enter below command to create a new file. Once created follow Step-2.
touch .bash_profile
Step-3
Save the below line)
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools
Step-4
Refresh the file using below command
$ source .bash_profile
$ echo $PATH
You should see your android path set in the output now.
Personally I just source my .bashrc in my .bash_profile:
echo 'source ~/.bashrc' >> ~/.bash_profile
So I put it in my .bashrc. And I'm using Android Studio, so it was a different path.
echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.bashrc
You may also want the following:
echo 'ANDROID_HOME=$HOME/Library/Android/sdk' >> ~/.bashrc
The simplest way to use adb command on your Mac systems would be to add the path to the platform-tools (where adb lives) into your bash_profile.
Steps to add the adb path:
1. open the bash_profile: This can be done by using the following commands
open ~/.bash_profile
This opens up the bash_profile in an editor.
Locate the platform_tools, usually they are present at the following location: Users/"user_folder"/Library/Android/sdk/platform_tools
Paste the following command in the bash_profile file which opens up:
export PATH=$PATH:/Users/A374375/Library/Android/sdk/platform-tools
Save the file using the command:
source ~/.bash_profile
Check if the path is saved by typing: echo $PATH : You should be able to find the entire path displayed in the output.
Type adb to see if the configuration worked. If you have any devices connected to the machine or any emulators running on your system they would be displayed when you type adb devices
output for adb devices
For Mac users :
Step 1: Install the Android Studio
Step2 : Open the terminal and type
cd
Step 3: Type below mentioned command changing the userName:
export PATH=“/Users/{user_name}/Library/Android/sdk/platform-tools”:$PATH
cd sdk/platform-tools/ and then use ./adb devices instead
On MacOS Big Sur do the following:
Open config file:
nano ~/.zshrc
Add paths to PATH variable:
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH
close file and save changes.
Then in terminal write:
source ~/.zshrc
And then you'll be able to run:
adb devices
adb kill-server
If you using zsh then you need do the add the following to your .zshrc
Steps:
Step 1: Open your .zshrc profile
open -e .zshrc
Step 2: Add the following to the file
export PATH=$PATH:/Users/${YourUser}/Library/Android/sdk/platform-tools
export ANDROID_HOME=/Users/${YourUser}/Library/Android/sdk
Step 3: Save the file and close.
Step 4: Reload the .zshrc
source .zshrc
Step 5: Check the devices connected
adb devices
MAC Solution.
cd /Users/<user>/Library/Android/sdk/platform-tools
./adb devices
if you are using Android Studio in MAC OS X , you could exec the following command in your terminal app:
echo 'alias adb="/Applications/Android\ Studio.app/sdk/platform-tools/adb"' >> .bashrc
exec $SHELL
and next:
adb devices
and you should be showing a list with your android devices connected via USB cable in your MAC, for example something like this:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
deb7bed5 device
For macOS Users Updated to MacOs Catalina,
~/.bash_profile changed to ~/.zshrc
So ,to run adb command and all other commands already exported to ~/.bash_profile easy walkaround is to export bash_profile to zshrc
To do that,
1) Navigate to the home directory in finder
2) I used Cmd + Shift + . to show the hidden files in Finder
3) Create .zshrc file if already not exist
4) Add line "source ~/.bash_profile" without quotes
5) Save
6) Quit and open terminal
start using adb devices
Here's a detailed manual:
http://codexpi.com/add-android-adb-path-mac-os-x-mavericks/
To sum this up:
Create and open the bash_profile file
touch .bash_profile
open -e .bash_profile
Add the path of the platform-tools folder (within the Android SDK)
export PATH="$PATH:/Users/USERNAME/PATH TO ANDROID SDK/platform-tools/
Run the command . .bash_profile to update (no need to restart the terminal)
If you are using ZSH and have Android Studio 1.3:
1. Open .zshrc file (Located in your home directory, file is hidden so make sure you can see hidden files)
2. Add this line at the end: alias adb="/Users/kamil/Library/Android/sdk/platform-tools/adb"
3. Quit terminal
4. Open terminal and type in adb devices
5. If it worked it will give you list of all connected devices
Mac OS
Open Terminal
touch ~/.bash_profile; open ~/.bash_profile
Copy and paste:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
command + S for save.
If you are setting the path in Catalina use below command one after another in the terminal. It's working fine for me.
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
source ~/.bash_profile
Commenting with some updated information from 2018.
Executable Binaries for Platform tools are made available for mac by Android here: https://developer.android.com/studio/releases/platform-tools.html
Download these to your mac. Place them in a directory e.g. I placed in ~/Software/platform-tools
If you have root access, the easiest way I have found on a mac is to add your directories to the list in /etc/paths. I like this way because after a few additions the $PATH starts to look too messy and hard to read, the /etc/pathshas everything in separate line, clean and organized. The downside is that you require root access.
$ cat /etc/paths # check contents of the file
$ sudo nano /etc/paths
Paste the full path of your platform-tools directory (something like /Users/GodZilla/Software/platform-tools/adb) at the end of this list and save. Quit and Open terminal again and check if it sees your platform-tools directory.
$ which adb
/Users/GodZilla/Software/platform-tools/adb
$ which fastboot
/Users/GodZilla/Software/platform-tools/fastboot
If you don't have root access, just add the platform-tools directory to $PATH in your .bash_profile (or .zshenv if you use zsh) as other users have suggested.
Download Android Platform Tools for macOS from:
https://developer.android.com/studio/releases/platform-tools
Extract to your somewhere e.g ~/installs/platform-tools
Add that folder to path by running:
echo 'export PATH=$PATH:~/installs/platform-tools' >> ~/.zshrc
Either restart terminal or run:
source ~/.zshrc
Assuming that you are using zsh.
This totally worked for me, after dickering around for a while after installing Android Studio:
Make sure you have the .bash_profile file. This should be in your [username] directory.
From whatever directory you are on, type this:
echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile
Now, usually you will have this exact path, but if not, then use whatever path you have the platform-tools folder
From the directory where your .bash_profile resides, type this:
. .bash_profile
Now type adb devices. You should see a "List of devices attached" response. Now you do not have to go to the platform-tools directory each and every time to type in the more cryptic command like, ./adb devices!!!
In my case, I installed Android studio, and have some apps (rust lang) that changes the ~/.profile, and adding adb to ~/.bash_profile made the rust un-executable, so I made the changes to the ~/.profile only, as:
$ echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.profile
$ source ~/.profile
$ adb --version
Android Debug Bridge version 1.0.41
Version 29.0.4-5871666
Installed as /Users/hasan/Library/Android/sdk/platform-tools/adb
In my case : I did the following (on a mac) :
backed up the ".bash_profile" and ".profile"
cleared all the android related paths.
created the new paths but this time around, I dragged the respective folders : { /.../sdk, /.../tools, /.../platform-tools } into the terminal. I did this for both ".bash_profile" and ".profile".
Then after successfully saving the files each. I restarted the terminal just to be sure about the modifications I made.
I then went on to test if adb was responding now ...
by typing : (in terminal) adb devices
I still had no luck (my devices) where not showing, then I restarted the adb, still.
I went on to do "android update adb" . This just killed and restarted the adb
I tried again still the devices wasnt showing.
I totally backed up my android device and resetted the whole phone back to factory default, went over to activate the device for development and allow for usb debugging in its settings > applications.
******** WORKED LIKE A CHARM ********
I tried again with the command "adb devices" and everything was back to normal the device was visible.
All the best. Just dont give up. It took me a lot of troubleshooting. All the best of luck.
Considering you have already downloaded SDK platform tools.
This command will set ADB locally. So if you close the terminal and open it again, ADB commands won't work until you run this command again.
export PATH=~/Library/Android/sdk/platform-tools:$PATH
These commands will set ADB globally. So once you run these commands no need to set them again next time.
echo 'export PATH=$PATH:~/Library/Android/sdk/platform-tools/' >> ~/.bash_profile
source ~/.bash_profile
If you are using zsh terminal do the following:
1) Open .zprofile file with the editor of your choice like "open -a xcode ~/.zprofile"
2) Add new PATH or Env Variable in .zprofile Save the file and quit the editor.
3) Execute your .zprofile to update your PATH: source ~/.zprofile
Add environment variable for Android Home Targetting Platform Tools
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
Restart Bash
source ~/.bash_profile
Now Check adb
Simply type
adb
on terminal
After trying all the solutions, none of them where working for me.
In my case I had the Android Studio and the adb was correctly working but the Android Studio was not capable to detect the adb. These was because I installed it with homebrew in another directory, not the /Users/$USER/Library/Android/sdk but Usr/Library blabla
Apparently AS needed to have it in his route /Users/$USER/Library/Android/sdk (same place as in preferences SDK installation route)
So I deleted all the adb from my computer (I installed several) and executed these terminal commands:
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
source ~/.bash_profile
adb devices
Well, after that, still wasn't working, because for some reason the route for the adb was /Users/$USER/Library/Android/sdk/platform-tools/platform-tools (yes, repeated) so I just copied the last platform-tools into the first directory with all the license files and started working.
Weird but true