Is there a way to automate the android sdk installation?

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

    To automate the sdkmanager.bat --licenses prompt away on Windows (say you're installing via automation for build infrastructure)... Don't run it. Don't waste time trying to figure out how to pipe y into it. I tried; abject fail.

    Rather - run it one time, yourself, and take note that it generates files into c:\android\android-sdk\licenses (where you're running c:\android\android-sdk\tools\bin\sdkmanager.bat - your install root may vary).

    Take those files, and place them somewhere you can grab them from in your automated setup scripts. Personally, ansible is my poison, so:

    # Note to future-us:
    # These are magical files generated by running `c:/android/android-sdk/tools/bin/sdkmanager.bat --licenses`
    # This, delightfully, is interactive, and wants to _actually_ read the keyboard buffer.
    # That's reputedly possible via SendKeys. I elected to not try that.
    # So, instead:
    # 1) remote to an instance like a cave-dweller
    # 2) run `c:/android/android-sdk/tools/bin/sdkmanager.bat --licenses` in a prompt.
    # 3) _actually type_ `y` however many godforsaken times you need to.
    # 4) meticulously harvest `c:/android/android-sdk/licenses/*` to this task.
    #    (you don't need the newline that they thoughtfully put before the hash in each file).
    - name: set up android licenses by hand
      win_lineinfile:
        path: c:/android/android-sdk/licenses/{{ item.name }}
        line: "{{ item.line }}"
        create: true
      with_items:
        - {name: "android-googletv-license", line: "SOME HASH"}
        - {name: "android-sdk-license", line: "SOME OTHER HASH"}
        ...
    

提交回复
热议问题