Is there a way to automate the android sdk installation?

后端 未结 12 2331
鱼传尺愫
鱼传尺愫 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:24

    For any one still searching for a method to download all Android packages, I have wrote a script to do that. It will download all non-obsoleted packages.

    #!/binbash
    # Install all non-obsolete android sdk packages.
    # author: Tai Le Tien (letientai299 at gmail.com)
    
    function install_sdk {
      android update sdk -u -s -a -t "$1"
    }
    
    function fetch_non_obsoled_package_indices {
      # Fetch the sdk list using non-https connections
      android list sdk -u -s -a |\
        # Filter obsoleted packages
        sed '/\(Obsolete\)/d' |\
        # Filter to take only the index number of package
        sed 's/^[ ]*\([0-9]*\).*/\1/' |\
        # Remove the empty lines
        sed -n 's/^[^ $]/\0/p'
    }
    
    for package_index in  $(fetch_non_obsoled_package_indices)
    do
      echo "====================================================================="
      echo "Start to install package:  ${package_index}"
      echo "====================================================================="
      # Auto accept license
      echo -e "y" | install_sdk "${package_index}"
      echo
      echo
    done
    

    You can also see it on my Github repo

    The good:

    • Not depend on expect.
    • Headless.

    The downsides:

    • You still have to install basic SDK manually, and put android into your path.
    • Script only works on unix.

提交回复
热议问题