problem configuring android sdk for nativescript on ubuntu machine - android

I've noticed there's no quick way of installing and configuring all nativescript dependencies on linux like windows and mac, so I followed the advanced setup guide for linux and all the commands ran successfully, however, when running tns doctor it tells me that android sdk is not installed or not configured correctly. everything else is giving me green check marks
here is what I did
Download android sdk
Extract it to /usr/local/android/sdk/
changed java version back to 8 since i had version 10 installed
run sudo sdkmanager "tools", sudo sdkmanager "build-tools" etc.
Made sure that the sdkmanager command is accessible without sudo
yet it doesn't work and I don't know why. any help please and thanks in advance.
here is the output of tns doctor
✔ Getting environment information
There seem to be issues with your configuration.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.3.0 version and is up to date.
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
✖ WARNING: The Android SDK is not installed or is not configured properly.
You will not be able to run your apps in the native emulator. To be able to run apps
in the native Android emulator, verify that you have installed the latest Android SDK
and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements
You are missing the nativescript-cloud extension and you will not be able to execute cloud builds. Your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options:
Select "Sync to Playground" to enjoy NativeScript without any local setup. All you need is a couple of companion apps installed on your devices.
Select "Configure for Cloud Builds" to install the nativescript-cloud extension and automatically configure your environment for cloud builds.
Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.
Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.
Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.
Edit:
here are the lines I've added to my ~/.bashrc file.
export JAVA_HOME=$(update-alternatives --query javac | sed -n -e 's/Best: *\(.*\)\/bin\/javac/\1/p')
export ANDROID_HOME="/usr/local/android/sdk"
export PATH="$PATH:$ANDROID_HOME/tools/:$ANDROID_HOME/platform-tools/:$ANDROID_HOME/tools/bin"
also here is the first part of the output of $ sdkmanager --list
Warning: File /home/mahmoud/.android/repositories.cfg could not be loaded.
Installed packages:=====================] 100% Computing updates...
Path | Version | Description | Location
------- | ------- | ------- | -------
build-tools;28.0.3 | 28.0.3 | Android SDK Build-Tools 28.0.3 | build-tools/28.0.3/
extras;android;m2repository | 47.0.0 | Android Support Repository | extras/android/m2repository/
extras;google;m2repository | 58 | Google Repository | extras/google/m2repository/
patcher;v4 | 1 | SDK Patch Applier v4 | patcher/v4/
platform-tools | 29.0.5 | Android SDK Platform-Tools | platform-tools/
platforms;android-28 | 6 | Android SDK Platform 28 | platforms/android-28/
tools | 26.1.1 | Android SDK Tools 26.1.1 | tools/

Look at this link for nativescript setup in ubuntu system. Because I am already follow that link for setup. https://docs.nativescript.org/start/ns-setup-linux.
Focus on step 5 for android sdk installation and anroid sdk path set in environment variable in ~/.bashrc file.

I had the same adventure:
Please consider & try the below:
1) Make sure you haven't edited the sdkmanager script, with the line:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
In case you did replace it with:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'
Then try something like:
$ANDROID_HOME/tools/bin/sdkmanager "build-tools;29.0.0"
and if all goes well, then the final check:
tns doctor

Related

Android Studio Arctic Fox 2020.3.1 Patch 1 'My Application' error - solved [duplicate]

I am getting this error in jitpack, I've tried everything on the internet. Below is my error
Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-26 Android SDK Platform 26
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
And when i run ./sdkmanager --licenses
All SDK package licenses accepted.======] 100% Computing updates...
Using sudo with the above command gives
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 5 more
additional error log
File /opt/android-sdk-linux/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 28.0.3 in /opt/android-sdk-linux/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 26 in /opt/android-sdk-linux/licenses
Warning: License for package Android SDK Platform 26 not accepted.
I don't know why it's checking for licenses there when my sdk location is other
You need to accept the licences before building.
According to Android SDK docs you can use the following command depending on the sdkmanager location: Docs on --licenses option seems to be missing though.
yes | sdkmanager --licenses
GNU/Linux Distributions:
yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses
macOS:
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
Windows:
%ANDROID_HOME%/tools/bin/sdkmanager --licenses
Flutter:
> flutter config --android-sdk 'path-of-android-sdk'(only for ubuntu user)
> flutter doctor --android-licenses
In Android Studio go to Tools -> SDK Manager.
Go to SDK Tools tab.
Select the Android SDK Command-line Tools (latest) and download by pressing Apply.
On Windows, you can find the sdkmanager.bat at
C:\Users\[your_user]\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
in Windows OS go to your sdkmanager path then execute
./sdkmanager.bat --licenses
You can find your sdkmanager in C:\Users\USER\AppData\Local\Android\Sdk\tools\bin
OR
For those people not using android studio on window os. Go to your cmdline-tools\tool\bin and type cmd on the directory box to open the directory in your terminal. Then run sdkmanager --licenses
To find your actual android SDK path follow the red marked area of the below picture
If you are working with Flutter then this command would definitely work for you.
flutter doctor --android-licenses
Problem: SDK license not accepted
Step 1: Open SDK Manager
After opening the SDK manager, open the SDK tools tab as shown below
Step 2: Check the option Show Package Details
It'll list out all the versions of SDK tools
Step 3: Install the required SDK tool version
Check the specific version of SDK tools that is complaining (for me, it was 29.0.3 as shown above in the first screenshot) from the list, accept the agreement in the dialog that opens next and you're done.
MacOS Catalina
Step 1: Changing Android Studio Preference
Open-up your Android Studio
Press Command+, or go to top-left AppBar Android Studio > Preferences.
From Left Pane, select Appearance > System Settings > Android SDK
Select SDK Tools next to SDK Platforms and under Android SDK Location
Check mark Android SDK Command-line Tools (latest) and Press OK button.
Wait for installation to be finished
Step 2 (For Flutter Users):
Go to Terminal and run the following command
flutter doctor --android-licenses
Step 2 (For Android Users):
Go to the Terminal and run the following command
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
You can accept the license agreements of the stated SDKs by going to the SDK Manager (Settings > [Search for Android SDK]) then find the packages noted in the error message and find them there. Chances are, you'll find SDKs that are not fully installed and installing them will ask you to accept the license agreement.
use android-28 with build-tools at version 28.0.3; or build-tools at version 26.0.3.
or try this: yes | sudo sdkmanager --licenses
This works for me:
yes | ./sdkmanager "platforms;android-28"
yes | ./sdkmanager "build-tools;28.0.3"
yes | ./sdkmanager --licenses
For Android Studio Arctic Fox, it was solved for me by installing the Google Play Licensing Library.
Go to Preferences
Expand Appearance & Behavior
Then expand System Settings
Select Android SDK and go to SDK Tools tab
Install Google Play Licensing Library
If you are getting this error while using Flutter then please run the below command on command prompt.
flutter doctor --android-licenses
If you get below error after running the above command
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Then please do the below steps
Open android studio
Go to SDK manager
Click on SDK tools tab
Install Android SDK command line tool
Run flutter doctor --android-licenses again
In Android Studio go to: Tools > SDK Manager > SDK Tools
On the bottom right, check the "Show Package Details" box and download the version of sdk that you need:
Tried this on Android Studio and it worked for me:
Tools > SDK Manager (Make sure to check Show Packages below)
SDK Platforms > Show Packages > Android - 28
SDK Tools > Show Packages > 28.0.3
Appears to be a bug at the momment:
https://issuetracker.google.com/issues/123054726
Solution that worked for me:
Create a .travis.yml file in your project directory and copy these lines:
before_script:
- mkdir "$ANDROID_HOME/licenses" || true
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
Reference:
https://github.com/square/RxIdler/pull/18/files
in Windows OS go to your sdkmanager path directory in cmd
You can find your sdkmanager in C:\Users\USER\AppData\Local\Android\Sdk\tools\bin
then execute the followwing command:
sdkmanager --licenses
after that it will ask to accept license agreement several times then accept all by just typing y on cmd
This works for me in Windows 10:
C:
cd \Users\YOUR_USER\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
sdkmanager.bat --licenses
After, yes to all
On Mac OS 10.15.1, I got the same error even after accepted all the licenses by running sdkmanager --licenses It worked after I updated the ANDROID_HOME path configuration in the ~/.bash_profile to the following
export ANDROID_HOME=/Users/your_username/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:~/Library/Android/sdk/platform-tools
And reload the ~/.bash_profile
source ~/.bash_profile
I tried many solutions but didn't work for me.
The below solution works for me.
locate the sdkmanager file in android SDK.
In my case :
~/Android/Sdk/tools/bin
go to that path : cd ~/Android/Sdk/tools/bin
Accept licenses manually : ./sdkmanager --licenses
Enter Yes or y
If you are using flutter go with the following steps
1.open the command prompt
Then the following command
2.C:\Users\niroshan>flutter doctor
And you will see the issues as follows
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10.0.17763.1339], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
X Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 4.1.0)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.50.1)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
Actually what you have to run is the below command
C:\Users\niroshan>flutter doctor --android-licenses
https://www.youtube.com/watch?v=g789PvvW4qo really helped me. What had done is open SDK Manager and download any new SDK Platform (dont worry it wont affect your desired api level).
Because with downlaoding any SDK Platforms(API level), you should accept licences. That's the trick worked for me.
I had the same problem when trying to run an app on my android device in a different project where I was working with some old version of tomcat8 and had to set the JAVA_OPTS variable and value. So I removed this system variable for JAVA_OPTS, which had a Variable value set to -Xms1024m (Remove the JAVA_OPTS system variable, but you can also store it for future use if you need to revert to using your old projects that might need it).
Then run the SDK manager bat file in your sdk path:
PS C:\Users[your_pc_username]\AppData\Local\Android\Sdk\tools\bin> .\sdkmanager.bat --licenses
Accept all licenses (Y).
How I solve this problem (AndroidStudio 4.2)
Click in Build tab
Select Failed to install the following Android SDK packages ... (warning)
Click Install missing SDK package(s)
On Ubuntu it still didn't work using the answers suggested.
This is what worked for me:
cd full-path-to-bin folder, where sdkmanager is located.
yes | ./sdkmanager --licenses --sdk_root="full-path-to-bin"
In the option --help it shows we can pass common args to it, which finally accepted ALL licences:
Usage:
...
sdkmanager --licenses [<common args>]
...
Common Arguments:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool
To add to the answers, you can also change to the sdkmanager directory and in a sub shell and accept the licenses there
(
cd /home/user/android-sdk-linux/tools/bin
yes | ./sdkmanager --licenses
)
I just done File -> Invalidate caches and restart
Then install missing packages.
Worked for me.
On Windows:
Add USER Environment variables:
NOTE: Path should be appended
JAVA_HOME %ProgramFiles%\Android\Android Studio\jre
ANDROID_SDK_ROOT %LocalAppData%\Android\Sdk
Path %LocalAppData%\Android\Sdk
Run the below command to accept licenses:
NOTE: Accept all licenses (say y)
%ANDROID_SDK_ROOT%/tools/bin/sdkmanager.bat --licenses
Now run your app:
(like below, or another command that failed for you):
cd \myapp\
react-native run-android
in my case I just installed a new version of android studio on a new laptop and cloned the old repository where
buildToolsVersion "30.0.2" at application level build.gradle.
I just upgraded to 30.0.3 which android studio recommended on its own and the problem went away
I moved my Sdks and Avds folder as it was using lots of memory in local disk c, but after that I got the above issue.
For me Invalidate Caches/Restart solve the issue
File->Invalidate Caches/Restart
In my case updating buildToolsVersion in app level build.gradle worked perfectly. If you don't know which to use you can create new project and copy buildToolsVersion from that into existing one.
A one liner solution with downgrade to java 8:
sudo apt-get install openjdk-8-jdk -y && export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 && flutter doctor --android-licenses

How to get latest build tool installed (locally) in android sdk using command line

Actually I am trying to get latest build tool installed in my machine.
But here I don't want to go through my file system, I am looking for Android SDK commands to figure out latest build tool installed in my system.
Not the prettiest or more stable trick but you can get the latest installed build tools by doing:
$ANDROID_HOME/tools/bin/sdkmanager --list | grep "build-tools/" | awk '{ print $3 }' | tail -1

How to install Android Virtual Device manager and intel system image with sdkmanager

I'm trying to create android emulator with only command line tools.
I've downloaded sdkmanager and successfully installed "platform"
sdkmanager "platforms;android-25". But I can't install system image, because
sdkmanager --list gives this
system-images;a...ult;armeabi-v7a | 4 | ARM EABI v7a System Image
system-images;a...-10;default;x86 | 4 | Intel x86 Atom System Image
system-images;a...pis;armeabi-v7a | 5 | Google APIs ARM EABI v7a Syste...
Someone decided that I don't need to see full names of packages that I want to install. But at the same time when trying to install something from this list sdkmanager seems to think otherwise.
In addition to the comment you received, you could also use the "android" script located in the tools folder, here is the output on my machine (I have truncated the output):
[user#pc:~/sdk/tools]
└─ $ ▶ ./android list sdk
******************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*********************************************************************
"android" SDK commands can be translated to sdkmanager commands on a
best-effort basis.
Continue? (This prompt can be suppressed with the --use-sdk-wrapper
command-line argument
or by setting the USE_SDK_WRAPPER environment variable) [y/N]: y
Running /home/user/sdk/tools/bin/sdkmanager --list --verbose
Info: Parsing /home/user/sdk/build-tools/24.0.3/package.xml
Info: Parsing /home/user/sdk/build-tools/25.0.2/package.xml
Info: Parsing /home/user/sdk/emulator/package.xml
Info: Parsing /home/user/sdk/patcher/v4/package.xml
...
Info: Parsing /home/user/sdk/tools/package.xml
Warning: File /home/user/.android/repositories.cfg could not be loaded.
Installed packages:
--------------------------------------
build-tools;24.0.3
Description: Android SDK Build-Tools 24.0.3
Version: 24.0.3
Installed Location: /home/user/sdk/build-tools/24.0.3
build-tools;25.0.2
Description: Android SDK Build-Tools 25.0.2
Version: 25.0.2
Installed Location: /home/user/sdk/build-tools/25.0.2
...
system-images;android-25;google_apis;x86_64
Description: Google APIs Intel x86 Atom_64 System Image
Version: 4
To make sure we are on the same page:
I have downloaded the file tools_r25.2.3-linux.zip from this site. Unzipped it into ~/sdk
I have this packages installed using the tools/sdkmanager:
build-tools;24.0.3
build-tools/25.0.2
emulator | 26.0.0
platform-tools | 25.0.4
platforms;android-24 | 2
platforms;android-25 | 3
tools | 26.0.1
Edit: After reading the whole command output, it turns out that you could also use the --verbose flag:
[user#pc:~/sdk/tools]
└─ $ ▶ sdkmanager --list --verbose

How do I download the Android SDK without downloading Android Studio?

As of the moment, I am running a Windows 8.1 PC that does not have the storage or the RAM for a IDE like Android Studio or Eclipse. I want to download the Android SDK tools, without the IDE. How can this be accomplished?
You can find the command line tools at the downloads page under the "Command line tools only" section.
These are the links provided in that page as of now (version 2022.1.1.20):
Windows no installer: https://dl.google.com/android/repository/commandlinetools-win-9477386_latest.zip
MacOS: https://dl.google.com/android/repository/commandlinetools-mac-9477386_latest.zip
Linux:
https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip
Be sure to have read and agreed with the terms of service before downloading any of the command line tools.
The installer version for windows doesn't seem to be available any longer, this is the link for version 24.4.1:
Windows installer: https://dl.google.com/android/installer_r24.4.1-windows.exe
Navigate to the "Get just the command line tools" section of the android downloads page, and download the tools for your system.
For Windows:
Extract the contents to C:\Android\android-sdk
Navigate to
C:\Android\android-sdk\tools\bin and open a command line window
(shift + right click)
Run the following to download the latest android package:
sdkmanager "platforms;android-25"
Update everything
sdkmanager --update
Other operation systems
Do pretty much the same, but not using windows directories.
The sdkmanager page gives more info in to what commands to use to install your sdk.
Command-line approach
mkdir android-sdk
cd android-sdk
wget https://dl.google.com/android/repository/sdk-tools-linux-*.zip
unzip sdk-tools-linux-*.zip
tools/bin/sdkmanager --update
When executing the above commands, make sure that you replace * with an appropriate version number which you could find in the download page.
Installing packages
You can also use the sdkmanager to list and to install any specific packages needed.
tools/bin/sdkmanager --list
tools/bin/sdkmanager "platform-tools" "platforms;android–27" "build-tools;27.0.3"
FYI
sdk-tools-linux-*.zip only includes the command-line tools. This extracts content to a single directory named tools, like:
+- android-sdk
+- tools
To get the SDK packages we could run:
tools/bin/sdkmanager --update
The sdkmanager accepts the following flag:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK
containing this tool
But if we omit this flag, it assumes parent directory of tools directory as the sdk root, here in our case android-sdk directory.
If you check the android-sdk folder after running tools/bin/sdkmanager --update it will be like:
+- android-sdk
+- tools
+- emulator
+- platforms
+- platform-tool
If needed, also set ANDROID_HOME environment variable like:
export ANDROID_HOME=/path/to/android-sdk
What worked for me on Windows:
Downloaded command line tools from https://developer.android.com/studio/index.html
Put the whole tools folder from the ZIP archive to C:\Program Files (x86)\Android SDK\
Launched tools\android.bat as administrator, which opened the usual SDK Manager window
Installed required components. The files were downloaded to ...\Android SDK\ directory (that is build-tools, platforms, platform-tools, etc. directories appeared alongside tools inside ...\Android SDK\)
Opened the Android project in Intellij IDEA, navigated to File->Project Structure->SDKs, and added Android SDK by directing to ...\Android SDK\ directory
This tutorial is a just step by step for installing Android SDK (Software Development Kit) assuming the user is starting from scratch.
There are just a couple of prerequisites to note:
Java runtime environment (or JDK) at Oracle website (and download the correct version (32- or 64-bit) for your computer).
A good internet connection (needed for downloading system images etc)
I recommed using the offline SDK installer for installing the essential tools namely SDK and AVD manager: The last version of he installer is found here: SDK Installer_r24.4.1 (for windows), SDK Installer_r24.4.1 (for linux) or SDK Installer_r24.4.1 (for macos)
For this guide I was using windows:
Here is the workthrough:
Depending on your choice download the appropriate SDK package from above links (but for this example I will be using the manual method)
After downloading the package, begin installation (and choose the desired installation folder to proceed or just leave the default %USERPROFILE%\android-sdk):
When done leave the option to download system images "checked":
Now we're in business...
The SDK manager window will appear, now you need to update/download other sdk packages (i.e platform-tools, system-images, platforms etc according to API levels)
Note: I recommend downloading x86 images as they're much faster tham arm counterparts, also get intel HAXM (hardware accelerated execution manager) driver to significantly increase your emulator speed
All set, now you just need to create and configure an Android virtual device matching your target Android version and tweak desired settings.
To do this click on the Tools tab in SDK manager and select manage AVDs, then in the following window click Create you'll see a similar screen as below:
After that boot the newly created virtual device.
Install applications and test as you wish ..
Command line only without sdkmanager (for advanced users / CI):
You can find the download links for all individual packages, including various revisions, in the repository XML file:
https://dl.google.com/android/repository/repository-12.xml
(where 12 is the version of the repository index and will increase in the future).
All <sdk:url> values are relative to https://dl.google.com/android/repository, so
<sdk:url>platform-27_r03.zip</sdk:url>
can be downloaded at https://dl.google.com/android/repository/platform-27_r03.zip
Similar summary XML files exist for system images as well:
(default) https://dl.google.com/android/repository/sys-img/android/sys-img.xml
(google_apis) https://dl.google.com/android/repository/sys-img/google_apis/sys-img.xml
For those using the latest distribution on windows, the following should be enough:
Download the command line tools from here
Extract it somewhere (e.g. C:\androidsdk)
Add ANDROID_SDK_TOOLS as environment variable pointing to where you extracted it (C:\androidsdk)
Create a folder named latest inside the cmdlime-tools you extracted. And move what's inside(bin,lib...) to the folder latest.
cd cmdline-tools/latest/bin and execute the following:
sdkmanager.bat system-images;android-29;default;x86_64 platforms;android-29 build-tools;29.0.3 extras;google;m2repository extras;android;m2repository
Agree to the terms and conditions and continue. voilà
Well the folks who are trying to download either on *ix or Ec2 machine would suggest to clean approach in below steps:
$ mkdir android-sdk
$ cd android-sdk
$ mkdir cmdline-tools
$ cd cmdline-tools
$ wget https://dl.google.com/android/repository/commandlinetools-linux-*.zip
$ unzip commandlinetools-linux-*.zip
The king - sdkmanager lives inside
cmdline-tools/tools/bin
, you'd better set in PATH environment variable.
but cmdline-tools should not be set as ANDROID_HOME. Because later, when updating Android SDK, or installing more packages, the other packages will be placed under ANDROID_HOME, but not under cmdline-tools.
The final, complete ANDROID_HOME directory structure should look like below, consist of quite a few sub-directories:
build-tools, cmdline-tools, emulator, licenses, patcher, platform-tools, platforms, tools.
You can easily point out that build-tools and cmdline-tools are siblings, all resides inside the parent ANDROID_HOME.
Add SDK tools directory in PATH environment variable to make executable available globally. Add below line either in ~/.bashrc or ~/.profile file to make it permanent.
In order to edit the ~/.bashrc simply can be editable in vim mode
$ vim .bashrc
Now set your preferred ANDROID_HOME in .bashrc file :
export ANDROID_HOME=/home/<user>/android-sdk
export PATH=${PATH}:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/platform-tools
here strange thing that we haven't download the platform-tools directory as of now but mentoning it under path but let it be as it will help you avoid remodification on the same file later.
Now go inside the same directory:
$ cd android-sdk
NOTE: well in first attempt sdkmanager command didnt found for me so I close the terminal and again created the connection or you can also refresh the same if it works for you.
after that use the sdkmanager to list and install the packages needed:
$ sdkmanager "platform-tools" "platforms;android-27" "build-tools;27.0.3"
Hence Sdkmanager path is already set it will be accessible from anywhere:
$ sdkmanager --update
$ sdkmanager --list
Installed packages:=====================] 100% Computing updates...
Path | Version | Description | Location
------- | ------- | ------- | -------
build-tools;27.0.3 | 27.0.3 | Android SDK Build-Tools 27.0.3 | build-tools/27.0.3/
emulator | 30.0.12 | Android Emulator | emulator/
patcher;v4 | 1 | SDK Patch Applier v4 | patcher/v4/
platform-tools | 30.0.1 | Android SDK Platform-Tools | platform-tools/
platforms;android-27 | 3 | Android SDK Platform 27 | platforms/android-27/
Install latest version from CLI without specifying version
Here is an approach to downloading the last version of the Android SDK from CLI.
First of all, create and move to the following dir:
mkdir -p ~/android-sdk/cmdline-tools
cd ~/android-sdk/cmdline-tools
Then download the SDK (it basically finds the download URL from the HTML and downloads it, if you go to the web page, you'll see that it only shows the last one, so it works):
curl -s https://developer.android.com/studio\#command-tools | grep -Eo 'https://dl.google.com/android/repository/commandlinetools-mac-[0-9]*_latest.zip' | head -n 1 | xargs wget
Unzip file
ls -A1 | xargs unzip
Sadly, straight from google, which is where you will want to download if your company firewall blocks other sources, Release 1.6 r1 September 2009 is the latest SDK they have.
To download the SDK over command line, the link has changed slightly than previously mentioned:
wget --quiet --output-document=/tmp/sdk-tools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}.zip
Latest version listed on the downloads page.
I downloaded Android Studio and installed it. The installer said:-
Android Studio => ( 500 MB )
Android SDK => ( 2.3 GB )
Android Studio installer is actually an "Android SDK Installer" along with a sometimes useful tool called "Android Studio".
Most importantly:-
Android Studio Installer will not just install the SDK. It will also:-
Install the latest build-tools.
Install the latest platform-tools.
Install the latest AVD Manager which you cannot do without.
Things which you will have to do manually if you install the SDK from its zip file.
Just take it easy. Install the Android Studio.
****************************** Edit ******************************
So, being inspired by the responses in the comments I would like to update my answer.
The update is that only (and only) if 500MB of hard disk space does not matter much to you than you should go for Android Studio otherwise other answers would be better for you.
Android Studio worked for me as I had a 1TB hard disk which is 2000 times 500MB.
Also, note: that RAM sizse should not a restriction for you as you would not even be running Android Studio.
I came to this solution as I was myself stuck in this problem. I tried other answers but for some reason (maybe my in-competencies) they did not work for me. I decided to go for Android Studio and realized that it was merely 18% of the total installation and SDK was 82% of it. While I used to think otherwise. I am not deleting the answers inspite of negative rating as the answer worked for me. I might work for someone elese with a 1 TB hard disk (which is pretty common these days).

How to check the Android developer tools version from the command line?

I'm trying to retrieve the ADT version to generate some system reports.
How can I check the version of the android developer tools installed on the system using the command line?
Various parts of the tools save their revision number in files
For example
cat /android/sdk/platform-tools/source.properties | grep Pkg.Revision
cat /android/sdk/tools/source.properties | grep Pkg.Revision
The build tools themselves are placed in versioned directories, so you can find them via
ls /android/sdk/build-tools/

Categories

Resources