Cannot install sdkmanager in windows 10 - android

I am trying to install the sdk manager alone for using it with Eclipse. I downloaded the zip file provided by google -
commandlinetools-win-6200805_latest.zip
from https://developer.android.com/studio
But as I try to run the sdkmanager.bat file it doesn't run and i am getting the following errors:
Error: could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
Please note that Java jdk path is set properly and there is no error with respect to that.
If you are interested to look at the bat file, here it is:
#if "%DEBUG%" == "" #echo off
#rem ##########################################################################
#rem
#rem sdkmanager startup script for Windows
#rem
#rem ##########################################################################
#rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%..
#rem Add default JVM options here. You can also use JAVA_OPTS and SDKMANAGER_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir=%~dp0\..
#rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
#rem set JAVA_EXE=C:/Program Files/Java/jdk1.8.0_241/bin/java.exe
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
#rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
#rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
#rem Setup the command line
set CLASSPATH=%APP_HOME%\lib\/sdkmanager-classpath.jar
#rem Execute sdkmanager
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS% -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli %CMD_LINE_ARGS%
:end
#rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable SDKMANAGER_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%SDKMANAGER_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
Any help appreciated

TL;DR;
copy the content of tools/lib/_ to tools/lib
run sdkmanager commands with --sdk_root parameter.
Details
In the line 66 of the sdkmanager.bat, CLASSPATH is defined to be like this
set CLASSPATH=%APP_HOME%\lib\/sdkmanager-classpath.jar
and inside the lib directory, sdkmanager-classpath.jar is, oddly, under a subdirectory called -.
I tried to change the path in the batch file but it did not work, so I copied the files from ..../tools/lib/_ to ..../tools/lib and the error disappeard. However, a warning appeared:
Warning: Could not create settings
java.lang.IllegalArgumentException
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
According to this answer, I tried to pass the --sdk_root parameter which worked without problems:
sdkmanager --sdk_root=%ANDROID_HOME% --list
# %ANDROID_HOME% is the environment variable that contains the path of android
# sdk installation. Typically, would be:
# `C:\Users\<USERNAME>\AppData\Local\Android\Sdk\tools`
PS: even I was able to solve this, I would say that this answer is a workaround since the documentation does not mention anything about copying files to other path

I post this for my short note upon the solution.
After done several research only specify sdk_root parameter solve Java problem.
sdkmanager --sdk_root=%ANDROID_HOME% --install [Package_name]
Where %ANDROID_HOME% specify a PATH to android SDK extracted. e.g. "d:\android-sdk"
Package_name can be obtained from --list option.
sdkmanager --sdk_root=%ANDROID_HOME% --list
I use this for Appium so only platform-tools, platforms [API Level] Should be fine. Emulator if you want to use AVD.

I also had the same problem and did not get any solution and one day by mistake I got the solution.
At first I kept the SDK folder wherever I wanted but this gave the error, so I kept it in the AppData folder (in Windows)
C:/Users/{username}/AppData
This folder is hidden by default, so either search for it in the address bar or enable to show the hidden folder and keep the SDK folder there

Related

ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

here is my error that showing when i run ./gradle --version
here is my java -version 17.0.2 that is set.
You find the java PATH: java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'
The result like this: java.home = /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
Add the line in you bash file (for me: ~/.zshrc): export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home (the path result above)
Have a look at the PATH environment variable. It should contain the path to your Java installation. After finding the installation directory set your JAVA_HOME environment variable to this path (but without the trailing /bin).

Unable to execute the Gluon “Getting Started” example for Eclipse and Android [duplicate]

I am trying to install the sdk manager alone for using it with Eclipse. I downloaded the zip file provided by google -
commandlinetools-win-6200805_latest.zip
from https://developer.android.com/studio
But as I try to run the sdkmanager.bat file it doesn't run and i am getting the following errors:
Error: could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
Please note that Java jdk path is set properly and there is no error with respect to that.
If you are interested to look at the bat file, here it is:
#if "%DEBUG%" == "" #echo off
#rem ##########################################################################
#rem
#rem sdkmanager startup script for Windows
#rem
#rem ##########################################################################
#rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%..
#rem Add default JVM options here. You can also use JAVA_OPTS and SDKMANAGER_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir=%~dp0\..
#rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
#rem set JAVA_EXE=C:/Program Files/Java/jdk1.8.0_241/bin/java.exe
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
#rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
#rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
#rem Setup the command line
set CLASSPATH=%APP_HOME%\lib\/sdkmanager-classpath.jar
#rem Execute sdkmanager
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS% -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli %CMD_LINE_ARGS%
:end
#rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable SDKMANAGER_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%SDKMANAGER_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
Any help appreciated
TL;DR;
copy the content of tools/lib/_ to tools/lib
run sdkmanager commands with --sdk_root parameter.
Details
In the line 66 of the sdkmanager.bat, CLASSPATH is defined to be like this
set CLASSPATH=%APP_HOME%\lib\/sdkmanager-classpath.jar
and inside the lib directory, sdkmanager-classpath.jar is, oddly, under a subdirectory called -.
I tried to change the path in the batch file but it did not work, so I copied the files from ..../tools/lib/_ to ..../tools/lib and the error disappeard. However, a warning appeared:
Warning: Could not create settings
java.lang.IllegalArgumentException
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
According to this answer, I tried to pass the --sdk_root parameter which worked without problems:
sdkmanager --sdk_root=%ANDROID_HOME% --list
# %ANDROID_HOME% is the environment variable that contains the path of android
# sdk installation. Typically, would be:
# `C:\Users\<USERNAME>\AppData\Local\Android\Sdk\tools`
PS: even I was able to solve this, I would say that this answer is a workaround since the documentation does not mention anything about copying files to other path
I post this for my short note upon the solution.
After done several research only specify sdk_root parameter solve Java problem.
sdkmanager --sdk_root=%ANDROID_HOME% --install [Package_name]
Where %ANDROID_HOME% specify a PATH to android SDK extracted. e.g. "d:\android-sdk"
Package_name can be obtained from --list option.
sdkmanager --sdk_root=%ANDROID_HOME% --list
I use this for Appium so only platform-tools, platforms [API Level] Should be fine. Emulator if you want to use AVD.
I also had the same problem and did not get any solution and one day by mistake I got the solution.
At first I kept the SDK folder wherever I wanted but this gave the error, so I kept it in the AppData folder (in Windows)
C:/Users/{username}/AppData
This folder is hidden by default, so either search for it in the address bar or enable to show the hidden folder and keep the SDK folder there

ruby dry run No such file or directory /platform-tools/adb (Errno::ENOENT)

how can i fix this problem ? when i using dryrun. log is here.
➜ ~ dryrun git#github.com:cesarferreira/android-helloworld.git
Searching for devices...
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/open3.rb:211:in
spawn': No such file or directory - /platform-tools/adb
(Errno::ENOENT) from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/open3.rb:211:in
popen_run' from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/open3.rb:99:in
popen3' from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/dryrun-0.8.1/lib/dryrun/dryrun_utils.rb:50:in
run' from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/dryrun-0.8.1/lib/dryrun/dryrun_utils.rb:46:in
run_adb' from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/dryrun-0.8.1/lib/dryrun.rb:108:inpick_device' from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/dryrun-0.8.1/lib/dryrun.rb:171:in call' from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/dryrun-0.8.1/bin/dryrun:5:in
' from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/bin/dryrun:23:in load' from
/Users/baidu/.rvm/rubies/ruby-2.0.0-p643/bin/dryrun:23:in'
The problem you're receiving is dryrun not being able to recognize an adb path. The adb path needs to be set to ANDROID_HOME, for dryrun to work.
Steps to Fix this:
echo export "ANDROID_HOME=/Users/yourName/Library/Android/sdk" >> ~/.bash_profile
source ~/.bash_profile
echo $ANDROID_HOME
Test dryrun git#github.com:cesarferreira/android-helloworld.git 🎉
From the documentation:
ANDROID_HOME needs to be set with the adb path.
Open the file ~/.bash_profile (~/.zshenv if you are using Zsh) or create it if it does not exist, and add the following (with your real Android SDK path):
export ANDROID_HOME=/Users/{your_user}/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
You need to set your ANDROID_HOME

create phonegap app using commande line

i try to create a phonegap application using cmd line create C:\testapp com.demo.testapp testapp i got this message something wrong in the loop
when i execute this commande i call the create.bat file which contain :
#ECHO OFF
IF NOT DEFINED JAVA_HOME GOTO MISSING
FOR %%X in (java.exe javac.exe ant.bat android.bat) do (
SET FOUND=%%~$PATH:X
IF NOT DEFINED FOUND GOTO MISSING2
)
cscript "%~dp0\create.js" %*
GOTO END
:MISSING
ECHO Missing one of the following:
ECHO JDK: http://java.oracle.com
ECHO Android SDK: http://developer.android.com
ECHO Apache ant: http://ant.apache.org
:MISSING2
ECHO something wrong in the loop
EXIT /B 1
so how can i fix the problem of java.exe , javac.exe, ant.bat and android.bat or how can i modify create.bat code ?!
the problem was that ant.bat does not exist ! i download the apache-ant-x.x.x-bin.zip and i extracted the file and i added the ant bin to my path variable and that's work correctly
and i used this phonegap zip for android cordova-android.zip which contain the correct create.bat and the correct create.js . see this tuto

android monkey runner scripts

i am tryig to execute a sample python program through monkey runner command prompt and it is throwing an error
Can't open specified script file
Usage: monkeyrunner [options] SCRIPT_FILE
-s MonkeyServer IP Address.
-p MonkeyServer TCP Port.
-v MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO,
WARNING, SEVERE, OFF)
Exception in thread "main" java.lang.NullPointerException
so any one can guide me how to resolve this one
scriptfile should be a full path file name
try below
monkeyrunner c:\test_script\first.py
try using something like
...\tools>monkeyrunner -v ALL first.py
where first.py was my sample python script which I copied into tools folder of android SDK (the place where monkeyrunner.bat is located)
Under all unix/linux families OS the sha bang syntax can be used.
Edit the first line of your script with the results of the following command:
which monkeyrunner
for example, if monkeyrunner (usually provided with android sdk) has been installed under /usr/local/bin/sdk write:
#!/usr/local/bin/sdk/tools/monkeyrunner
or even use "env"
#!/usr/bin/env monkeyrunner
then set you script file as executable
chmod +x <script>
You can now launch your script from the shell.
It looks not make sense to switch working directory to Android SDK folder but just for obtain some relative references path for itself. It means you have to specify the full path for your script file and the PNG image files you want to save or compare to.
A better way is modify few lines in the "monkeyrunner.bat" under your SDK folder as below. This will use your current path as working directory, so, no necessary to use full path file name.
rem don't modify the caller's environment
setlocal
rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0
rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
rem cd /d %~dp0
rem Check we have a valid Java.exe in the path.
set java_exe=
call %~sdp0\lib\find_java.bat
if not defined java_exe goto :EOF
set jarfile=monkeyrunner.jar
set frameworkdir=
set libdir=
if exist %frameworkdir%%jarfile% goto JarFileOk
set frameworkdir=%~sdp0\lib\
if exist %frameworkdir%%jarfile% goto JarFileOk
set frameworkdir=%~sdp0\..\framework\
:JarFileOk
set jarpath=%frameworkdir%%jarfile%
if not defined ANDROID_SWT goto QueryArch
set swt_path=%ANDROID_SWT%
goto SwtDone
:QueryArch
for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
:SwtDone
if exist %swt_path% goto SetPath
echo SWT folder '%swt_path%' does not exist.
echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
exit /B
:SetPath
call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir%;%swt_path% -Dcom.android.monkeyrunner.bindir=%frameworkdir%\..\..\platform-tools\ -jar %jarpath% %*
I met the same things as you did, I resolved by using "monkeyrunner" command under tools, and your script file should be a full path name. It looks like the directory “tools” is the main directory of MonnkeyRunner. I am depressed that I can't run my script files by pydev IDE directly.
monkeyrunner.bat cygpath -w $(pwd)/monkey.py

Categories

Resources