This is a script that create a program object that you can use to list and download Android SDK.
It download the current Android SDK and libraries as I write this.
Prerequisite: java and android-sdk_r24.4.1-windows.zip (as previously found
through) unpacked to a folder
- Just run the script by double clicking on it.
- It search your computer for the unpacked sdk, copy itself and files it need and create a program object (if possible).
- Double click on the program object and type "update sdk --filter 3,2,1" and follow the instructions.
repeat the procedure with the packages you want to download, use "list sdk" to list available packages.
The script add "--no-ui --no-https" as it doesn't work otherwise.
Please also note that I don't know if you can actually develop something with the downloaded files, that is up to you to find out.
It was intended to act as a subsystem for development with NetRexx to create apps for Android, but I didn't persue it further since there are so few examples and information on how to actually code NetRexx apps and deploy them on Android.
/*
* Filename: android.cmd
* Author: JanErik
* Created: Sun Sep 11 2016
* Purpose: Install SDK for Android in OS/2
* Changes: Mon Sep 16 2019 Changes to program object and startup configuration.
* Require: Zip SDK (such as android-sdk_r24.4.1-windows.zip), downloads updates live.
*/
'@echo off'
'@mode 80,102'
'@cls'
/* Set up prog to be the path of this script, including following symlinks,
and set up progdir to be the fully-qualified pathname of its directory. */
PARSE SOURCE . . prog
PARSE ARG params
IF LENGTH( STRIP( params ) ) = 0 THEN
params = '-h'
/* Grab current directory before we change it */
work_dir = DIRECTORY()
/* Change current directory and drive to where the script is, to avoid
issues with directories containing whitespaces. */
PARSE VALUE REVERSE( prog ) WITH fname'\'this
this = REVERSE( this )
CALL DIRECTORY this
/* Load RexxUtil Library */
IF RxFuncQuery('SysLoadFuncs') THEN
DO
CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
CALL SysLoadFuncs
END
env = 'ENVIRONMENT'
/* Check we have a valid Java.exe in the path.*/
IF VALUE( 'JAVA_HOME',, env ) = '' THEN
DO
CALL SysGetEA this, 'JAVA_HOME', 'java_path'
IF STREAM( java_path'\JAVA.EXE', 'C', 'QUERY EXISTS' ) = "" THEN
java_path = ''
IF LENGTH( java_path ) < 2 THEN DO
PARSE UPPER VALUE rxFind( 'JAVA.EXE', ' -version', 'VERSION "1.' ) WITH java_path'\BIN'
IF LENGTH( java_path ) = 0 THEN
DO
CALL LINEOUT 'STDERR', 'JAVA engine not found'
RETURN 1
END
CALL SysPutEA this, 'JAVA_HOME', java_path
END
END
ELSE java_path = VALUE( 'JAVA_HOME',, env )
CALL SysGetEA this, 'ANDROID_PATH', 'android_path'
IF STREAM( android_path'\android.bat', 'C', 'QUERY EXISTS' ) = "" THEN
android_path = ''
IF LENGTH( android_path ) < 2 THEN DO
PARSE VALUE rxFind( 'android.bat' ) WITH android_path
IF LENGTH( android_path ) = 0 THEN
DO
CALL LINEOUT 'STDERR', 'Android SDK not found'
RETURN 2
END
CALL SysPutEA this, 'ANDROID_PATH', android_path
END
ext = 'cmd ico png'
DO i = 1 TO 3
IF STREAM( android_path'\android.'SUBWORD( ext, i, 1 ), 'C', 'QUERY EXISTS' ) = '' THEN
IF SysCopyObject( this'\android.'SUBWORD( ext, i, 1 ), android_path ) = 1 THEN
CALL LINEOUT 'STDERR', 'Copied android.'SUBWORD( ext, i, 1 )' to "'android_path'"'
END
IF TRANSLATE( android_path ) <> TRANSLATE( this ) THEN
DO
this = android_path
work_dir = android_path
END
objID = 'ANDROID'
android_name = 'Android'
android_wps = 'Android SDK'
IF wpsObjectExist( '<WP_'objID'>' ) = 0 THEN
DO
setupstring = 'OBJECTID=<WP_'objID'>;NOAUTOCLOSE=YES;EXENAME='this'\android.cmd;PARAMETERS=[Specify parameter (list sdk --filter 1)];ICONFILE='this'\'android_name'.ico;'
IF SysCreateObject( 'WPProgram', android_wps, '<WP_DEVFLDR>', setupstring, 'U' ) <> 1 THEN
CALL SysCreateObject 'WPProgram', android_wps, '<WP_DESKTOP>', setupstring, 'U'
CALL rxAddBigIcon this'\'android_name'.png', '<WP_'objID'>'
END
jar_path = 'lib\sdkmanager.jar;lib\swtmenubar.jar'
/* Set SWT.Jar path based on current architecture (x86 or x86_64)*/
CALL DIRECTORY this
swt_path = ''
DO WHILE LENGTH( swt_path ) = 0
DO WHILE QUEUED() > 0; PARSE PULL; END
'@'java_path'\bin\java.exe -jar lib\archquery.jar|rxqueue'
PARSE PULL swt_path
END
MkTempCopy:
/* Copy android.bat and its required libs to a temp dir.
This avoids locking the tool dir in case the user is trying to update it.*/
tmp_dir = VALUE( 'TEMP',,'ENVIRONMENT' )'\temp-android-tool'
cpy = swt_path'\* common.jar commons-codec* commons-compress* commons-logging dvlib.jag gson* guava* httpclient* httpcore* httpmime* layoutlib-api.jar org-eclipse-* sdk* swtmenubar.jar'
DO i = 1 TO WORDS( cpy )
cpyfile = 'lib\'SUBWORD( cpy, i, 1 )
IF POS( '*', cpyfile ) > 0 THEN
DO
CALL SysFileTree this'\'cpyfile, 'file.', 'SFO'
DO j = 1 TO file.0
CALL rxCpyFile this, file.j, tmp_dir
END
END
ELSE CALL rxCpyFile this, this'\'cpyfile, tmp_dir
END
/* jar_path and swt_path are relative to PWD so we don't need to adjust them, just change dirs.*/
tools_dir = android_path
CALL DIRECTORY tmp_dir
EndTempCopy:
/* The global ANDROID_SWT always override the SWT.Jar path */
IF VALUE( 'ANDROID_SWT',,'ENVIRONMENT' ) <> '' THEN
swt_path = VALUE( 'ANDROID_SWT',,'ENVIRONMENT' )
ELSE
swt_path = this'\lib\'swt_path
IF DIRECTORY( swt_path ) = '' THEN
DO
CALL LINEOUT 'STDERR', 'ERROR: SWT folder "'swt_path'" does not exist.'
CALL LINEOUT 'STDERR', 'Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.'
RETURN 2
END
SetPath:
/* Finally exec the java program and end here.
REMOTE_DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000*/
IF 0 = POS( TRANSLATE( java_path ), TRANSLATE( VALUE( 'PATH',,'ENVIRONMENT' ) ) ) THEN
CALL VALUE 'PATH', java_path'\bin;'||STRIP( VALUE( 'PATH',,'ENVIRONMENT' ),, ';' ), 'ENVIRONMENT'
IF 0 = POS( TRANSLATE( tools_path ), TRANSLATE( VALUE( 'PATH',,'ENVIRONMENT' ) ) ) THEN
CALL VALUE 'PATH', tools_path'\lib;'||STRIP( VALUE( 'PATH',,'ENVIRONMENT' ),, ';' ), 'ENVIRONMENT'
CALL DIRECTORY tools_dir
'@java "-Dcom.android.sdkmanager.toolsdir='tools_dir'" "-Dcom.android.sdkmanager.workdir='work_dir'" -classpath "'jar_path';'swt_path'\swt.jar" com.android.sdkmanager.Main 'params' --no-ui --no-https'
CALL DIRECTORY work_dir
RETURN rc
rxCpyFile: PROCEDURE
PARSE VALUE REVERSE( SUBSTR( ARG(2), LENGTH( ARG(1) ) + 1 ) ) WITH fname'\'fpath
fpath = REVERSE( fpath )
rc = rxMkDir( ARG(3)fpath )
IF rc = 0 & STREAM( ARG(3)fpath'\'REVERSE( fname ), 'C', 'QUERY EXISTS' ) = '' THEN
rc = SysCopyObject( ARG(2), ARG(3)fpath )
RETURN rc
rxChk: PROCEDURE
DO WHILE QUEUED() > 0; PARSE PULL; END;
'@'||ARG(1)||ARG(2)||' 2>>&1 | RXQUEUE'
DO WHILE QUEUED() > 0
IF POS( TRANSLATE( ARG(3) ), TRANSLATE( LINEIN( 'QUEUE:' ) ) ) > 0 THEN
IF LENGTH( ARG(4) ) > 0 THEN RETURN ARG(4)
END
RETURN ''
rxFind: PROCEDURE EXPOSE !_msg_!.
env = 'ENVIRONMENT'
PARSE VALUE REVERSE( SysSearchPath( 'PATH', ARG(1) ) ) WITH fname'\'fpath
fpath = REVERSE( fpath )
fname = REVERSE( fname )
IF ARG() > 1 & LENGTH( fpath ) > 0 THEN
fspec = rxChk( fpath'\'fname, ARG(2), ARG(3), fpath )
ELSE IF STREAM( fpath'\'fname, 'C', 'QUERY EXISTS' ) <> '' THEN
fspec = fpath
ELSE fspec = ''
IF LENGTH( fspec ) > 0 THEN RETURN fspec
CALL LINEOUT 'STDERR', VALUE( 'PROGRAMS',, env )
IF POS( '*', ARG(1) ) = 0 THEN fname = '*'ARG(1)
ELSE fname = ARG(1)
CALL SysFileTree VALUE( 'PROGRAMS',, env )'\'fname, 'file.', 'SFO'
DO i = 1 TO file.0
PARSE VALUE REVERSE( file.i ) WITH .'\'fspec
IF ARG() > 1 THEN
fspec = rxChk( file.i, ARG(2), ARG(3), REVERSE( fspec ) )
ELSE
fspec = REVERSE( fspec )
IF LENGTH( fspec ) > 0 THEN RETURN fspec
END
drives = SysDriveMap( 'C:', 'USED' )
DO j = 1 TO WORDS( drives )
CALL LINEOUT 'STDERR', SUBWORD( drives, j, 1 )
CALL SysFileTree SUBWORD( drives, j, 1 )||'\'fname, 'file.', 'SFO'
DO i = 1 TO file.0
PARSE VALUE REVERSE( file.i ) WITH .'\'fspec
IF ARG() > 1 THEN
fspec = rxChk( file.i, ARG(2), ARG(3), REVERSE( fspec ) )
ELSE
fspec = REVERSE( fspec )
IF LENGTH( fspec ) > 0 THEN RETURN fspec
END
END
RETURN ''
rxMkDir: PROCEDURE
rc = ( DIRECTORY( ARG(1) ) = '' )
IF rc = 1 THEN
IF \rxMkDir( STRIP( FILESPEC( 'D', ARG(1) )FILESPEC( 'P', ARG(1) ), 'T', '\' ) ) THEN
rc = SysMkDir( ARG(1) )
Return rc
rxAddBigIcon: PROCEDURE EXPOSE !_msg_!. java_path
crlf = D2C(13)D2C(10)
bigicons_dir = VALUE( 'BIGICONS',, 'ENVIRONMENT' )
bigicon = FILESPEC( 'N', ARG(1) )
objid = ARG(2)
IF LENGTH( bigicons_dir ) > 0 THEN
DO
IF STREAM( ( bigicons_dir'\'bigicon ), 'C','QUERY EXISTS') = '' THEN
IF SysCopyObject( ARG(1), bigicons_dir ) = 0 THEN
RETURN 1
IF STREAM( bigicons_dir'\bigicons.txt', 'C', 'QUERY EXIST' ) <> '' THEN
DO
f_size = STREAM( bigicons_dir'\bigicons.txt', 'C', 'QUERY SIZE' )
IF f_size > 0 THEN
DO
input = CHARIN( bigicons_dir'\bigicons.txt', 1, f_size )
CALL STREAM bigicons_dir'\bigicons.txt', 'C', 'CLOSE'
PARSE UPPER VALUE input WITH pre'"'(bigicon)'"'post
IF LENGTH( post ) > 0 THEN RETURN 2
PARSE UPPER VALUE input WITH pre'"'(objid)'"'post
IF LENGTH( post ) > 0 THEN RETURN 3
PARSE VALUE input WITH pre'[OBJECTID]'mid(crlf)(crlf)'['post
input = pre'[OBJECTID]'STRIP( STRIP( mid, 'T', D2C(10) ), 'T', D2C(13) )||crlf||LEFT( '"'objid'"', 28 )'"'bigicon'"'crlf||crlf'['post
CALL SysFileDelete bigicons_dir'\bigicons.txt'
CALL CHAROUT bigicons_dir'\bigicons.txt', input
CALL STREAM bigicons_dir'\bigicons.txt', 'C', 'CLOSE'
END
ELSE RETURN 4
END
END
RETURN 0
/* Code borrowed from REXX Tips & Tricks v3.60 */
wpsObjectExist: PROCEDURE /* parameter: '<new_wps_object_id>', return: 1 exist, 0 doesn't exist, 43 error */
PARSE ARG objID
rc = 43 /* init return/error code 43 = routine not found */
SIGNAL ON SYNTAX NAME ObjectExistError
IF SUBSTR( objID, 2, 1 ) <> ":" THEN
IF LEFT( objID, 1 ) <> "<" & RIGHT( objID, 1 ) <> ">" THEN
objID = "<" || objID || ">"
/* create the object and see if it fail */
tempRC = SysCreateObject( "WPFolder", "TestObject", "<WP_NOWHERE>", "OBJECTID=" || objID || ";", "FAIL" )
IF tempRC = 1 THEN
DO
CALL SysDestroyObject objID
rc = 0
END
ELSE
rc = 1
ObjectExistError:
RETURN rc