How to install SDK manager on linux ubuntu 16.04? - android

I was trying to install Android SDK with the help of the SDK command line tools downloaded from the link https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
on my Linux Ubuntu 16.04 PC.
i run the command following command for installation
./android update sdk
but the installation has stopped and gave the following message on terminal
------------------------------------------------------------------------------------------------------------------------------------
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/Android/Sdk/bin/sdkmanager --update
Warning: java.net.SocketException: Connection reset
Warning: Failed to download any source lists!
Done
-----------------------------------------------------------------------------------------------------------------------------------
how to solve this error.or suggest me a way to install android sdk on my linux pc without installing android studio.

A bit late, but in the same situation. It looks like this isn't an error, but the way the tools evolved: they are pushing users to use Android Studio if they want the GUI for the sdk manager, it's usable only from the IDE.
You still have the command line available at bin/sdkmanager in this folder from the download, and instructions can be found here, but they are not great, either, so I'll share what I did:
downloaded the latest compressed file from this page (link way down there)
unzipped somewhere (I chose /opt/Android/android-sdk)
created a symlink to add sdkmanager to my path (ln -s /opt/Android/android-tools/bin/sdkmanager ~/.local/bin/sdkmanager)
installed platform tools and build tools for kitkat and up using sdkmanager "platform-tools" "platforms;android-19" "build-tools;19.1.0" (sudo may be needed)
You can check the versions available using sdkmanager --list, and figure what you need to support and download tools for other versions. The download will not show any kind of progress, it'll only tell you it's done after a while.
I suppose it's not a big deal to keep Android Studio installed solely to have access to the sdk manager GUI, but I'll make do with the command line tools. That's very shady of Google, specially to people not really into their hacked up Intellij version.

Related

Android Sdk Manager Failed to download any source list

I'm trying to download platform-tools from Sdk Manager. but when I run :C:\Users\tavak\AppData\Local\Android\Sdk\tools\bin\sdkmanager --list
or any other commands related like \sdkmanager platform-tools
I get this error :
Warning: Failed to download any source lists!
Warning: java.io.FileNotFoundException: https://dl.google.com/android/repository/repository2-1.xml
The antivirus is disabled , and I'm running a proxy in whole device. I can successfully open the url in my browser. help me if possible !
If you are using proxy, you need to specify your proxy settings:
sdkmanager --list --verbose --no_https --proxy=http --proxy_host=127.0.0.1 --proxy_port=8118
maybe the best solution for a person under blockade like me , is using faster proxys or I can download the sdk parts , manually. the needed ones include :
platform-tools
builds
emulator
platforms
...
It really bothers but no way !

'apkanalyzer' is not recognized as an internal or external command

I often compare my new build apk size with the production build and I am looking for options to automate this activity such that it compares both new and prod apk sizes and reports me.
I am aware of APK Analyzer of Android Studio but I want to do that using command-line tools. This doc lists the usage of apkanalyzer but upon running this command
apkanalyzer -h apk file-size myapk.apk
It says "'apkanalyzer' is not recognized as an internal or external command, operable program or batch file." though I have already set the environment path to \Android\sdk\tools\bin.
Not sure why command-line is not recognizing this command, could you let me know where I could possibly have gone wrong or is there any other way to check apk file size using command-line?
Thanks for any help in advance.
apkanalyzer is unix shell script, here converted batch script for windows, make sure to change APP_HOME and CLASSPATH to match your setup. save it as apkanalyzer.cmd
#echo off
::##############################################################################
::##
::## apkanalyzer start up script for Windows
::##
::## converted by ewwink
::##
::##############################################################################
::Attempt to set APP_HOME
SET SAVED=%cd%
SET APP_HOME=C:\android\sdk\tools
SET APP_NAME="apkanalyzer"
::Add default JVM options here. You can also use JAVA_OPTS and APKANALYZER_OPTS to pass JVM options to this script.
SET DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir=%APP_HOME%
SET CLASSPATH=%APP_HOME%\lib\dvlib-26.0.0-dev.jar;%APP_HOME%\lib\util-2.2.1.jar;%APP_HOME%\lib\jimfs-1.1.jar;%APP_HOME%\lib\annotations-13.0.jar;%APP_HOME%\lib\ddmlib-26.0.0-dev.jar;%APP_HOME%\lib\repository-26.0.0-dev.jar;%APP_HOME%\lib\sdk-common-26.0.0-dev.jar;%APP_HOME%\lib\kotlin-stdlib-1.1.3-2.jar;%APP_HOME%\lib\protobuf-java-3.0.0.jar;%APP_HOME%\lib\apkanalyzer-cli.jar;%APP_HOME%\lib\gson-2.3.jar;%APP_HOME%\lib\httpcore-4.2.5.jar;%APP_HOME%\lib\dexlib2-2.2.1.jar;%APP_HOME%\lib\commons-compress-1.12.jar;%APP_HOME%\lib\generator.jar;%APP_HOME%\lib\error_prone_annotations-2.0.18.jar;%APP_HOME%\lib\commons-codec-1.6.jar;%APP_HOME%\lib\kxml2-2.3.0.jar;%APP_HOME%\lib\httpmime-4.1.jar;%APP_HOME%\lib\annotations-12.0.jar;%APP_HOME%\lib\bcpkix-jdk15on-1.56.jar;%APP_HOME%\lib\jsr305-3.0.0.jar;%APP_HOME%\lib\explainer.jar;%APP_HOME%\lib\builder-model-3.0.0-dev.jar;%APP_HOME%\lib\baksmali-2.2.1.jar;%APP_HOME%\lib\j2objc-annotations-1.1.jar;%APP_HOME%\lib\layoutlib-api-26.0.0-dev.jar;%APP_HOME%\lib\jcommander-1.64.jar;%APP_HOME%\lib\commons-logging-1.1.1.jar;%APP_HOME%\lib\annotations-26.0.0-dev.jar;%APP_HOME%\lib\builder-test-api-3.0.0-dev.jar;%APP_HOME%\lib\animal-sniffer-annotations-1.14.jar;%APP_HOME%\lib\bcprov-jdk15on-1.56.jar;%APP_HOME%\lib\httpclient-4.2.6.jar;%APP_HOME%\lib\common-26.0.0-dev.jar;%APP_HOME%\lib\jopt-simple-4.9.jar;%APP_HOME%\lib\sdklib-26.0.0-dev.jar;%APP_HOME%\lib\apkanalyzer.jar;%APP_HOME%\lib\shared.jar;%APP_HOME%\lib\binary-resources.jar;%APP_HOME%\lib\guava-22.0.jar
SET APP_ARGS=%*
::Collect all arguments for the java command, following the shell quoting and substitution rules
SET APKANALYZER_OPTS=%DEFAULT_JVM_OPTS% -classpath %CLASSPATH% com.android.tools.apk.analyzer.ApkAnalyzerCli %APP_ARGS%
::Determine the Java command to use to start the JVM.
SET JAVACMD="java"
where %JAVACMD% >nul 2>nul
if %errorlevel%==1 (
echo ERROR: 'java' command could be found in your PATH.
echo Please set the 'java' variable in your environment to match the
echo location of your Java installation.
echo.
exit /b 0
)
:: execute apkanalyzer
%JAVACMD% %APKANALYZER_OPTS%
While checking the output of appium-doctor command - The following error was seen -
android, apkanalyzer could NOT be found in /Users/{user_name}/Library/Android/sdk!
The solution was to enable Android SDK Command-line tools from Android Studio Preferences
Checkout the screenshot
Hope this helps
APK Analyzer tool is available in android studio https://developer.android.com/studio/build/apk-analyzer.html.
Most the command executable options can be used just with the good UI available in the Android Studio.
The apkanalyzer file (with no extension) in my sdk>tools>bin installed on my windows 10 pc is a Unix Shell script.
Windows doesn't recognize this file as a valid command.
This appears to be a bug in the windows install of the Android SDK Tools 26.1.1.
This means that apkanalyzer does not exist in your SDK path.
To download it, just got to SDK Manager and click on Android SDK Tools, then click Ok to continue and download the missing tools.
SDK manager
As others have mentioned, make sure you have installed the Android SDK Tools via the SDK Manager. They should show up in <your_sdk_root>/tools/bin. A long time ago I added <your_sdk_root>/tools to my $PATH in my ~/.bash_profile, but never added <your_sdk_root>/tools/bin; apparently I missed the note that as of SDK Tools, Revision 25.3.0 tools were deprecated or otherwise moved to there among other places.
Seee also
https://developer.android.com/studio/command-line/ for details on the regular Tools, Build, Platform, and Emulator tools.
In Android Studio > Tools > sdkmanager > install Android SDK Command line tools
This worked for me!
I've submitted a bug report to Google: https://issuetracker.google.com/issues/124064881
Apparently it's broken on Windows.
be sure that Android Studio "Commandline Tools" installed on your system.
Then, add the following information into your system path;
C:\Users\user\AppData\Local\Android\Sdk\tools
C:\Users\user\AppData\Local\Android\Sdk\tools\bin
C:\Users\user\AppData\Local\Android\Sdk\cmdline-tools\latest
C:\Users\user\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
It worked for me..
M. Yaşar Özden

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).

the sdk manager won't open after trying everything

I have installed the Android SDK but I can't get the Adroid SDK manager to open.
I have looked everywhere on the internet and this is what I have already done which didn't help:
1. run sdk as administrator
2. adding a path pointing to the JDK in all of these forms :
C:\Program Files\Java\jdk1.7.0_21\bin;%SystemRoot%\system32;
C:\Program Files\Java\jdk1.7.0_21\bin;
C:\Program Files\Java\jdk1.7.0_21\
C:\Program Files\Java\jdk1.7.0_21
C:/Program Files/Java/jdk1.7.0_21/bin;
none of them worked ..:-(
3.
Step #1: Open up a command prompt.
Step #2: Use the cd command to move to wherever you installed your Android SDK.
Step #3: Run tools\android.
after doing it I got an error message that said that :
ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java installed on your system.
4. deleting 3 times the sdk and reinstalling it.
5. Deleting the .android folder from the user (C:/Users/[User Name]) directory
By the way I have Windows 7 , and I have downloaded the 64 -bits sdk.
I am so helpless.. I ll appreciate a lot a solution...
Shiran
I had the same problem. Try to add an environment variable :
JAVA_HOME : "C:\Java\jdk1.7.0_25\".
It solves problem for me.
WRT Ubuntu 14.04:
You may not have java installed globally in your machine. My fix was to do:
sudo apt-get install openjdk-7-jdk
After was I able to run the SDK Manager.

Installed Android SDK and ADT but command prompts not working

I have downloaded the software and installed it for Android SDK I am then adding this command into the command prompt C:\Program Files\Android\android-sdk\platform-tools and it will not find the path.
I am not sure what to do, I don't know where platform tools sits on my computer and I am very nearly there but am completely stuck.
I have also tried most of these commands and they are not working either
How to Use Android ADB Command Line Tool
To set environment variables at runtime, you can use following steps.
set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

Categories

Resources