Is there a way to automate the android sdk installation?

后端 未结 12 2342
鱼传尺愫
鱼传尺愫 2020-11-27 08:41

Now I have to download and install the Android SDK and AVD Manager, and then install the APIs, tools through the UI. Is there a way to automate this process?

12条回答
  •  悲哀的现实
    2020-11-27 09:37

    Yet another script to download only needed, non-{obsolute,source,emulator-image,doc} packages:

    #!/bin/bash
    set -e
    
    # cd into where tools/android can be found
    if [[ -d "$ANDROID_HOME" ]]; then
      cd "$ANDROID_HOME"
    elif [[ -x "$(dirname "$0")/tools/android" ]]; then
      cd "$(dirname "$0")"
    else
      echo "FAILED: Cannot find ANDROID_HOME/tools/android"
      exit 1
    fi
    
    android () {
      "$(dirname $0)/tools/android" "$@"
    }
    
    needed_packages () {
      android list sdk -u -s -e         \
        | grep '^id:'                   \
        | cut -d'"' -f2                 \
        | grep -v 'source'              \
        | grep -v 'sys-img'             \
        | grep -v 'doc'                 \
        | paste -d, -s -
    }
    
    main () {
      (while : ; do
      echo 'y'
      sleep 1
      done) | android update sdk -u -s -a -t "$(needed_packages)"
    }
    
    main
    

    Some parts are taken from other answers in this thread.

提交回复
热议问题