Android sdk command line tools linux

How to install Android SDK Build Tools on the command line?

The result is that nothing in folder build-tools, and I want is aapt and apkbuilder, since I want to build apk from command line without ant.

20 Answers 20

By default, the SDK Manager from the command line does not include the build tools in the list. They’re in the «obsolete» category. To see all available downloads, use

And then to get one of the packages in that list from the command line, use:

Where -u stands for —no-ui, -a stands for —all and -t stands for —filter.

If you need to install multiple packages do:

android update sdk -u -a -t 1,2,3,4. n

Where 1,2. n is the package number listed with the list command above

If you are missing build-tools like 18.1.1 then this is the right way to install it using the command line.

@DanielJonker Yes, it is. Just echo «yes» to the command, i.e. echo yes | android update sdk —all —filter tools —no-ui —force > /dev/null

echo «yes» can be shortened to echo «y» , but that doesn’t work in all cases anyway. In some cases you can get more than one y/n license prompt, depending on the filter and specific packages. echo «y» will respond to the first prompt only, but not the rest. I’m trying to make it work with yes command with no success so far.

@AlexanderMalakhov I agree, if your host OS has the utility, using it is the best option. I looked at expect first, but in my case I have to run the script on a certain Linux distributive running in AWS cloud. That distro does not have expect installed and I don’t have enough rights to install it as part of build plan. After looking around, the best solution that I found is

 # update Android SDK on headless server FILTER=tool,platform,android-20 ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) \ | android update sdk --no-ui --all \ --filter $

As mentioned in other answers, you can use the —filter option to limit the installed packages:

android update sdk —filter .

The other answers don’t mention that you can use constant string identifiers instead of indexes (which will change) for the filter options. This is helpful for unattended or scripted installs. Man for —filter option:

. This also accepts the identifiers returned by ‘list sdk —extended’.

android list sdk —all —extended :

Packages available for installation or update: 97 ---------- id: 1 or "tools" Type: Tool Desc: Android SDK Tools, revision 22.6.2 ---------- id: 2 or "platform-tools" Type: PlatformTool Desc: Android SDK Platform-tools, revision 19.0.1 ---------- id: 3 or "build-tools-19.0.3" Type: BuildTool Desc: Android SDK Build-tools, revision 19.0.3 

Then you can use the string ids as the filter options to precisely specify the versions you want:

Читайте также:  Профиль qt make install linux

android update sdk —filter tools,platform-tools,build-tools-19.0.3 etc

android update will also require the —all option, otherwise usage help is displayed. For example: android update sdk —no-ui —all —filter build-tools-21.1.0 (and +1 for the —extended option which allows you to see the aliases like build-tools-21.1.0 )

I was looking for that —extended option so I could write a script and use it in my Continuous Integration Server where it can refresh the sdk resources itself. Nice tip !

Version 25.2.3 (and higher) of Android SDK Tools package contains new tool — sdkmanager — which simplifies this task of installing build-tools from the command line.
It is located in android_sdk/tools/bin folder.

Usage (from documentation):

List installed and available packages:

sdkmanager --list [options] \ [--channel=channel_id] // Channels: 0 (stable), 1 (beta), 2 (dev), or 3 (canary) 

Use the channel option to include a package from a channel up to and including channel_id. For example, specify the canary channel to list packages from all channels.

Install packages:

sdkmanager packages [options] 

The packages argument is an SDK-style path, wrapped in quotes (for example, «build-tools;25.0.0» or «platforms;android-25» ). You can pass multiple package paths, separated with a space, but they must each be wrapped in their own set of quotes.

Example usage (on my Mac):

alex@mbpro:~/sdk/tools/bin$ ls ../../build-tools/ 25.0.0/ alex@mbpro:~/sdk/tools/bin$ ./sdkmanager "build-tools;25.0.2" done alex@mbpro:~/sdk/tools/bin$ ls ../../build-tools/ 25.0.0/ 25.0.2/ 

You can also specify various options, for example to force all connections to use HTTP ( —no_https ), or in order to use proxy server ( —proxy_host=address and —proxy_port=port ).

To check the available options, use the —help flag. On my machine (Mac), the output is as following:

alex@mbpro:~/sdk/tools/bin$ ./sdkmanager --help Usage: sdkmanager [--uninstall] [] \ [--package_file ] [. ] sdkmanager --update [] sdkmanager --list [] In its first form, installs, or uninstalls, or updates packages. is a sdk-style path (e.g. "build-tools;23.0.0" or "platforms;android-23"). is a text file where each line is a sdk-style path of a package to install or uninstall. Multiple --package_file arguments may be specified in combination with explicit paths. In its second form (with --update), currently installed packages are updated to the latest version. In its third form, all installed and available packages are printed out. Common Arguments: --sdk_root=: Use the specified SDK root instead of the SDK containing this tool --channel=: Include packages in channels up to . Common channels are: 0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary). --include_obsolete: With --list, show obsolete packages in the package listing. With --update, update obsolete packages as well as non-obsolete. --no_https: Force all connections to use http rather than https. --proxy=: Connect via a proxy of the given type. --proxy_host=: IP or DNS address of the proxy to use. --proxy_port=: Proxy port to connect to. * If the env var REPO_OS_OVERRIDE is set to "windows", "macosx", or "linux", packages will be downloaded for that OS. 

Источник

Читайте также:  About system kali linux

Install OpenJDK, Android command line tools and Android SDK on Ubuntu

Installing OpenJDK with Android SDK and tools

If you want to develop an Android application or game, it’s essential to have Java Development Kit (JDK), Android command line tools, and the SDK. With utilities like keytool , you can generate app signing keys, with, adb debug the application on a real device, with sdkmanager you can install Android SDKs and so on.

In this tutorial you will learn how to install OpenJDK, Android command line tools and SDK on Debian/Ubuntu Linux system without having to install heavy Android Studio. It also may be suitable for other Linux distributions, just make sure to install proper packages.

Install OpenJDK 11

To install Open Java Development Kit version 11.0.16+ (it will install the latest), run the following commands:

sudo apt update sudo apt install openjdk-11-jdk

After installation, you can check if Java installed by running java -version and javac -version . It should output the current version of tools.

Configure environment variables

Java tools will be installed in JAVA_HOME environment variable. Therefore you need to set this variable properly. Also, add /bin subdirectory from Java home to PATH , so programs from there are accessible without prefixes. To do so, add this to the end of your ~/.bashrc file:

export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))) export PATH=$PATH:$JAVA_HOME/bin

First command takes full path to java executable, reads this symbolic link, gets parent of the parent directory and sets the final value to JAVA_HOME variable. Second command appends bin directory from JAVA_HOME to PATH . Relaunch your terminal or run source ~/.bashrc to read new variables.

Install Android command-line tools

I recommend downloading Android packages from the official Android developer website instead of using your Linux distribution Android packages. Go to https://developer.android.com/studio/#command-tools and download the Linux archive.

Screenshot from developer.android.com with cursor hovering over command line tools zip archive for Linux

Read Android Software Development Kit License Agreement and confirm to continue. Then navigate to Downloads and install the tools:

cd ~/Downloads unzip commandlinetools*.zip sudo cp cmdline-tools/bin/* $JAVA_HOME/bin/ sudo cp -r cmdline-tools/lib/* $JAVA_HOME/lib/

Install Android SDK

Create a directory where Android SDK will be installed ( ~/Android/Sdk is the recommended path):

Now you need to install Android SDK. I used the command below. I took it from Godot Engine Android export guide.

sdkmanager --sdk_root=$HOME/Android/Sdk "platform-tools" "build-tools;30.0.3" "platforms;android-31" "cmdline-tools;latest" "cmake;3.10.2.4988404" "ndk;21.4.7075529"

Enter ‘y’ if you accept license terms. Wait for the command to finish execution. Next, set up Android-related environment variables:

export ANDROID_HOME=$HOME/Android/Sdk export ANDROID_SDK_ROOT=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools

Relogin to your shell or run source ~/.bashrc and test if tools are installed properly. For example, you can check your version of ADB using adb —version . Your should see something like this if everything is installed correctly:

Android Debug Bridge version 1.0.41 Version 33.0.2-8557947 Installed as /home/bob/Android/Sdk/platform-tools/adb

Источник

How to Install Android SDK without Android Studio on Ubuntu

Android SDK consists of a collection of tools that help developers to create Android applications. It comes with tools such as Build Tools, Platform Tools, Emulator, Jetifier, and command line tools.

Читайте также:  Управление компьютером linux android

When you install Android Studio, the Android SDK comes along with it. Some developers may prefer to use their own preferred text editor or IDE and only need SDK tools for their development.

In this tutorial, we learn how to install Android SDK without android studio on a Ubuntu.

Prerequisites

Step 1. Setup Directory for Android SDK

First, create a directory structure to set up SDK Tool. In my case, going to place it in my home directory under ~/android/sdk directory.

For creating the directory, type:

Step 2. Download Android command-line tools

Visit the Android Studio download page and grab the link to download sdk command line tool. This would be at the bottom of the webpage in the section «Command line tools only» and contained in a zip file.

Note: This package is generic for all Linux Distributions. We have tested only on Ubuntu. Should work on other Linux Distros as well.

Android command line tool

Change to the sdk directory created before:

Download the zip file using wget command:

sudo wget https://dl.google.com/android/repository/commandlinetools-linux-9123335_latest.zip

Once downloaded, extract the .zip file using the unzip command:

sudo unzip commandlinetools-linux-9123335_latest.zip

Once extraction is completed, you will have a new directory named cmdline-tools. Now change to that directory.

Let’s create a new directory inside cmdline-tools to hold all bin and lib contents.

Now you can move everything inside the cmdline_tools directory to the tools directory.

Step 3. Let the system know SDK Location

For the SDK command line tool to work, we have to set up environment variables properly. For this let us set the ANDROID_HOME environment variable and update the PATH variable.

export ANDROID_HOME=$HOME/android/sdk export PATH=$ANDROID_HOME/cmdline-tools/tools/bin/:$PATH export PATH=$ANDROID_HOME/emulator/:$PATH export PATH=$ANDROID_HOME/platform-tools/:$PATH

android sdk $Path settings

To make the changes permanent, you would need to add these commands to your shell profile file (e.g. .bash_profile or .bashrc).

Step 4. Install Android SDKs from Command Line

The Android SDK command line tools package comes with sdkmanager command. This tool is used to manage the packages and components of the Android SDK. Commonly used to list, install and update packages.

To list all installed and available packages, type

sdkmanager --list or sdkmanager --list --channel=channel_id // Channels: 0 (stable), 1 (beta), 2 (dev), or 3 (canary)

The output is a long list of packages. You can use filter the list using grep — for example sdkmanager —list | grep package-name.

To install packages use the following syntax:

sdkmanager --install packages [options]

Some of the useful packages are platform tools, build tools, and emulator. To install those packages using sdkmanager, type:

sdkmanager --install "platform-tools" "build-tools;30.0.1" "emulator" "platforms:android-33"

To keep all packages on the latest version update packages use sdkmanager —update command.

Conclusion

In this tutorial, we learned how to install Android SDK without actually installing the full android studio. This is more useful for guys who are more interested to stick on the command line.

Thanks for reading, if you encounter any issues please leave a comment.

If this resource helped you, let us know your care by a Thanks Tweet. Tweet a thanks

Источник

Оцените статью
Adblock
detector