3 # Attempt to set app_home
4 # Resolve links: $0 may be a link
6 # Need this for relative symlinks.
7 while [ -h "$prg" ] ; do
9 link
=`expr "$ls" : '.*-> \(.*\)$'`
10 if expr "$link" : '/.*' > /dev
/null
; then
13 prg
=`dirname "$prg"`"/$link"
17 cd "`dirname \"$prg\"`" >/dev
/null
19 cd "$saved" >/dev
/null
21 ANDROID_WRAPPER_BIN_DIR
=${ANDROID_WRAPPER_BIN_DIR:-$app_home/bin}
22 ANDROID_WRAPPER_SDK_TIMEOUT
=${ANDROID_WRAPPER_SDK_TIMEOUT:-20}
25 "*************************************************************************
26 The \"android\" command is deprecated.
27 For manual SDK, AVD, and project management, please use Android Studio.
28 For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
29 *************************************************************************"
32 echo "Invalid or unsupported command \"$@\""
34 echo "Supported commands are:"
35 echo "android list target"
36 echo "android list avd"
37 echo "android list device"
38 echo "android create avd"
39 echo "android move avd"
40 echo "android delete avd"
41 echo "android list sdk"
42 echo "android update sdk"
54 if [[ $arg =~ ^
- ]]; then
57 if [[ -z $verb && $verbs =~
( |^
)$arg( |$
) ]]; then
61 if [[ -n $verb && $objects =~
( |^
)$arg( |$
) ]]; then
67 return $
([[ -n $verb && -n $object ]])
70 function echo_and_exec
{
76 function parse_filter
{
79 if [[ $filter == tool ||
$filter == platform-tool ||
$filter == doc
]]; then
80 command+=( "$args ${filter}s" )
81 elif [[ $filter == tools ||
$filter == platform-tools
]]; then
82 command+=( "$args ${filter}" )
83 elif [[ $filter =~ ^lldb
]]; then
84 command+=( "$args ${filter/-/;}" )
85 elif [[ $filter =~ ^build-tools
]]; then
86 command+=( "$args ${filter/build-tools-/build-tools;}" )
87 elif [[ $filter == ndk
]]; then
88 command+=( "$args ndk-bundle" )
89 elif [[ $filter =~ ^android-
]]; then
90 command+=( "$args platforms;$filter" )
92 echo Filter
$filter not supported
98 function confirm_try_sdk
{
100 if [[ $arg == --use-sdk-wrapper ]]; then
104 if [[ -n $USE_SDK_WRAPPER ]]; then
107 read -t $ANDROID_WRAPPER_SDK_TIMEOUT -p "\"android\" SDK commands can be translated to sdkmanager commands on a best-effort basis.
108 Continue? (This prompt can be suppressed with the --use-sdk-wrapper command-line argument
109 or by setting the USE_SDK_WRAPPER environment variable) [y/N]: " trysdkresponse
110 if (( $?
> 128 )); then
111 echo "Timed out waiting for input."
112 echo "To suppress this prompt, run with --use-sdk-wrapper or set USE_SDK_WRAPPER."
115 if [[ ${trysdkresponse,,} == y
]]; then
122 avd_verbs
="list create move delete"
123 avd_objects
="avd target device"
125 if matches
"$avd_verbs" "$avd_objects" "$@"; then
126 echo_and_exec
"$ANDROID_WRAPPER_BIN_DIR/avdmanager" "$@"
129 sdk_verbs
="list update"
132 if matches
"$sdk_verbs" "$sdk_objects" "$@"; then
134 if [[ $verb == list
]]; then
135 echo_and_exec
"$ANDROID_WRAPPER_BIN_DIR/sdkmanager" --list --verbose
137 if [[ $verb == update
]]; then
138 command=( "$ANDROID_WRAPPER_BIN_DIR/sdkmanager" )
142 if [[ $arg == --use-sdk-wrapper ||
$arg == $verb ||
$arg == $object ]]; then
144 elif [[ $arg == -n ]]; then
145 echo "update sdk -n is not supported"
147 elif [[ $arg == -s ||
$arg == --no-https ]]; then
148 command+=("--no_https")
149 elif [[ $arg == -a ||
$arg == --all ]]; then
150 command+=("--include_obsolete")
151 elif [[ $arg == -p ||
$arg == --obsolete ||
$arg == -u ||
$arg == --no-ui ||
$arg == --proxy-host ||
152 $arg == --proxy-port ||
$arg == -t ||
$arg == --filter ]]; then
154 elif [[ $prev == --proxy-host ]]; then
155 command+=("--proxy=http" "--proxy_host=$arg")
156 elif [[ $prev == --proxy-port ]]; then
157 command+=("--proxy_port=$arg")
158 elif [[ $prev == -t ||
$prev == --filter ]]; then
162 echo Unrecognized argument
$arg
168 if [[ -n $update_all ]]; then
169 command+=("--update")
171 echo_and_exec
${command[@]}