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

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

Related

How to install SDK manager on linux ubuntu 16.04?

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.

Trouble running android command in command line

I've set up my paths to point to the Android SDK tools via this command:
# Cordova command line tools for Android SDK ----------------------
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
When I echo out the $PATH, this is what I get:
/Users/lorenzoignacio/.rvm/gems/ruby-2.0.0-p0/bin:/Users/lorenzoignacio/.rvm/gems/ruby-2.0.0-p0#global/bin:/Users/lorenzoignacio/.rvm/rubies/ruby-2.0.0-p0/bin:/Users/lorenzoignacio/.rvm/bin:/usr/local/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/Users/lorenzoignacio/.local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/go/bin:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
If you look at the end of it, you see my path:
/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
And yet when I try to run the cordova platform add android I get:
[Error: The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: /bin/sh: android: command not found]
The entire adt-bundle is located in my root user directory in a directory called Development. The exact path is /Users/me/Development/adt-bundle/
What Am I missing?
What Am I missing?
You are missing two ~ characters, perhaps.
The exact path is /Users/me/Development/adt-bundle/
That's not what you typed into your PATH. Your PATH says that there is no /Users/me -- instead, PATH is expecting a /Development directory in the root of your volume.
Now, in Linux, the solution would be to add a ~ to indicate that /Development is relative to your home directory:
export PATH=${PATH}:~/Development/adt-bundle/sdk/platform-tools:~/Development/adt-bundle/sdk/tools
My OS X shell experience is rusty, so I forget if ~ will map to /Users/me or not. If it does, use ~, otherwise, go with:
export PATH=${PATH}:/Users/me/Development/adt-bundle/sdk/platform-tools:/Users/me/Development/adt-bundle/sdk/tools
Thanks to #CommonsWare for helping me out with my $PATH issues.
In addition to the solution, it turns out that the latest ADT only contains Android Target 18.
Phonegap v3.0.9 seems to run Android Target 17, so I downloaded that and it now works wonderfully.

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

how can i launch the android tool?

I need to do somethings that must be done from the command prompt of the android tool.
but every one says it's in the platform tools folder in the sdk path but which file is it?
that might help:
the contents of platform tools folder:
aapt.exe
adb.exe
aidl.exe
dexdump.exe
dx.bat
fastboot.exe
llvm-rs-cc.exe
source.properties
AdbWinApi.dll
AdbWinUsbApi.dll
Did you mean android Adb command lin tool if so see this link
if you want to manage emulator from command line see these three link it will help you a lot
Android Emulator
Using the Android Emulator
Android Emulator on Linux
There is an android command, but it's not an executable - run the android.bat in the tools directory, and you should be able to make the changes you need. If you add the tools directory to your system path, you'll be able to run android from any directory when using the command line.

NDK - Error trying to generate a build.xml file for Hello-jni

I just installed Android NDK, r5b, and while trying to follow the steps from Exploring the hello-jni Sample, on the command line I receive the error:
MacBook-2:~ mvermant$ cd ndk/samples/hello-jni
MacBook-2:hello-jni mvermant$ android update project -p . -s
-bash: android: command not found
I'm using Eclipse Helios release 2 with Android SDK r10 and ADT 10.0.0 on MAC 10.6.6. I have also checked to have GNU Make 3.81, and installed GNU Awk(though I am not sure it's in the right place).
I've searched a lot, and seems there might be a class path missing somewhere, but I can't figure out where exactly and what to do to fix it.
You should make sure the tools directory of your android-sdk is on your (shell) path.
Something like:
export PATH="/path/to/sdk/tools:$PATH"
before you execute your command.
In general you will also need two other directories to be on your path:
/path/to/sdk/platform-tools - for adb and other android sdk tools
/path/to/ndk - for ndk-build and ndk-gdb, which are ndk tools
You can also do some setup so that you don't have to run these commands every time you open Terminal.

Categories

Resources