Recently I had to use some tools from the Android SDK on Linux and it was surprisingly not as straightforward as I thought it'll be. Perhaps Google was trying to convince folks to use Android Studio...
Anyways, the first step is to download the command-line tools from Android Developers. (Click on "Download Options" for more options.) Grab the zip file for command-line tools and unzip it to a folder of choice. You should see a tools
folder, with the necessary binaries in the bin subfolder.
If you get a Warning: Could not create settings
error when trying to run tools/bin/sdkmanager
, that's because the tools directory hierarchy has been changed starting from Android SDK Command-line Tools 1.0.0 (6200805). (Refer to the excellent answer by Jing Li on Stack Overflow here.) The solution therefore, is to move the unzipped tools
folder into the cmdline-tools
subfolder, and add cmdline-tools/tools/bin
to your path.
Assuming the sdkmanager is located at /home/<username>/cmdline-tools/tools/bin/sdkmanager
, one would add the following to their bash profile (~/.bashrc
):
export PATH=$PATH:/home/<username>/cmdline-tools/tools/bin
Exit and restart the terminal, and the Android SDK command-line tools should work now. Some useful commands:
$ sdkmanager --help
$ sdkmanager --list
$ sdkmanager --install <package>
Note: to use certain tools such as apkanalyzer
, one would also need to install the necessary packages with sdkmanager
.
No comments:
Post a Comment