kyle shanks
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: 'SDK Manager' disqus: kyleAlien --- SDK Manager === ## OverView of Content [**SDK Manager 官方介紹**](https://developer.android.com/studio/command-line/sdkmanager) 若對指令有問題則使用 sdkmanager --help 就可以查看其他指令 & 格式,底下會先說幾個常使用的指令 [TOC] ## sdkmanager 概述 sdkmanager工具在 Android SDK 工具擴展(25.2.3及更高版本)中提供,並位於`<android_sdk>/tools/bin` 目錄下,若有需要可以把該連接放置到環境變數 > ![](https://i.imgur.com/gxZMtCK.png) ### 查看資訊 list * 指令格式 ```shell= sdkmanager --list [options] \ [--channel=channel_id] // Channels: 0 (stable), 1 (beta), 2 (dev), or 3 (canary) ``` :::success * **版本 channel 分類** 1. **Canary**(金絲雀):Bleeding Edge(一種最新、但並非完美的技術),大約週更,這是最早被發布的預覽版本,建議在安裝 Canary 版本時同時安裝一個 Stable or Beta 版本 2. **Dev**(開發版): 跟 Canary 的差異主要是有經過 **完整的測試** 3. **Beta**(Beta版): 基於穩定版的 Canary 版本, 4. **Stable**(穩定版): Android Developer 網站上獲得的穩定版本 ::: ```shell= # 列出所有 sdk 列表 sdkmanager --list ``` > ![](https://i.imgur.com/A00hTvw.png) :::info * 若需要列出全部的穩定版(Stable) 請使用 `--channel=0` 或是 `完全移除 --channel` 指令 ::: :::warning * JDK 版本造成的異常 這個錯誤是由於Java 9及更高版本中的模塊化系統所引起的,該系統導致某些類和庫在默認情況下無法訪問 ```shell= Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init> ``` 1. 下載 JDK90 以下的版本,並切換預設版本為 JDK 使用 ```shell= # 下載 JDK 8 sudo apt install openjdk-8-jdk # 並切換預設為 JDK 8 sudo update-alternatives --config java ``` ::: ### 透過 sdkmanager 下載 Packages * 指令格式 (Package) ```shell= sdkmanager --install packages [options] ``` **==packages 代表了路徑==**,這些路徑可以使用 `--list` 查看 > Ex: build-tools;19.1.0 > ![reference link](https://i.imgur.com/fuR3Di6.png) 1. 安裝 `build-tools` ```shell= sdkmanager --install "build-tools;29.0.3" ``` > ![](https://i.imgur.com/R46dfJw.png) 去 SDK `build-tools` 就可以看到新下載的 29.0.3 > ![](https://i.imgur.com/1itUqxM.png) 2. 安裝 `NDK` ```shell= sdkmanager --install 'ndk;20.1.5948944' ``` > ![](https://i.imgur.com/VeSqozF.png) 3. 安裝 `emulator` ```shell= sdkmanager --install emulator ``` > ![](https://i.imgur.com/ttUMGw7.png) ### 卸載 Package * 指令格式 ```shell= sdkmanager --uninstall packages [options] sdkmanager --uninstall --package_file=package_file [options] ``` 解除安裝 `build-tools;29.0.1` ```shell= sdkmanager --uninstall "build-tools;29.0.1" ``` > ![](https://i.imgur.com/FOMZdPH.png) ### 升級已安裝 Package * 指令格式 ```shell= sdkmanager --update [options] ``` > ![](https://i.imgur.com/rxG1mJu.png) ### 其他設置 Options * 上面有列出一對中括弧的 options,可以透過 `sdkmanager --help` 查找詳細用法 | Options 指令 | 說明 | | -------- | -------- | | -\-sdk_root=<path\> | 安裝到指定的 SDK 路徑而不是包含此工具的 SDK (用 SDK 來位另外一個 SDK 安裝東西) | | -\-channel=<channel id\> | 如同上面在列 --list 相同,可以選擇 0(Stable), 1(Beta), 2(Dev), 3(Canary) 版本,**未設定則下載 stable** | | -\-include_obsolete | 包含過期的版本,**配合 --list、--update 使用** | | -\-no_https | 使用 http 下載 | | -\-verbose | 列出詳細內容 | | -\-proxy={http \\| socks} | 通過給定代理建立連結,用 http 指定一個高層級協議(如 HTTP 或 FTP)的代理,或用 socks 指定一個 SOCKS(V4 或 V5)代理 | | -\-proxy_host={IP_address \\| DNS_address} | 使用代理的 IP & DNS 地址 | | -\-proxy_port=<port_number\> | 要連結到的代理 Port 號 | * 使用 verbose 列出下載細項 ```shell= # 下載 build tools 26.0.0 sdkmanager --install "build-tools;26.0.0" --verbose ``` > ![](https://i.imgur.com/kugKFUn.png) ## Ubuntu - sdkmanager ### command 下載 Cmdline sdkmanager * 到 [**Android 官方網站**](https://developer.android.com/studio?gclid=Cj0KCQjwpImTBhCmARIsAKr58cywedJ3OJ5nwLWSkEDZCmWOxI5NECEO7IqZjM8HzoUphUSHQe-4znQaAgFQEALw_wcB&gclsrc=aw.ds) 下載最新版本的 Cmdline sdkmanager ```shell= # 下載官方提供的 SDKManager 包 wget https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip # 解壓縮 zip 包 unzip commandlinetools-linux-8092744_latest.zip ``` * 將 `sdkmanager/bin` 的路徑放置到所有人 (當然可以放到個人) 的環境變數中 ```shell= sudo vim /etc/profile # ----------------------------------------------- # /etc/profile export TOOLS_DIR=/home/alien/tools export PATH=$ANDROID_CMD:$NDK:$EMULATOR:$PATH # ----------------------------------------------- source /etc/profile ``` :::warning * `cmdline-tools : could not determine` SDK root 錯誤!無法抓取到 SDK 的根目錄,解決辦法是 1. 在下載的好的 `cmdline-tools` 資料夾下創建 `lastest` 目錄 2. 將所有的檔案移動至 `lastest 目錄下` > ![](https://i.imgur.com/zFZkMDO.png) 3. 再次執行 sdkmanager 就可以使用了 :+1: ::: ### 下載 NDK、Emulator * 透過 sdkmanager --list 可以查看到當前發布的所有 sdk 檔案,其中就有包括 NDK、SDK、Emulator 等等 1. 下載 NDK ```shell= sdkmanager --list | grep ndk sdkmanager --install 'ndk;24.0.8215888' ``` 2. 下載 Emulator ```shell= sdkmanager --install emulator ``` * 將下載好的工具目錄設定到 `/etc/profile` 中的 PATH,之後就可以讓所有使用者都使用到 ```shell= export TOOLS_DIR=/home/alien/tools export ANDROID_CMD=$TOOLS_DIR/android/cmdline-tools/lastest/bin export NDK=$TOOLS_DIR/android/ndk/24.0.82.15888 export EMULATOR=$TOOLS_DIR/android/emulator export PATH=$ANDROID_CMD:$NDK:$EMULATOR:$PATH ``` ### 查看已下載 Packages * 查看已下載 Packages `--list_installed` ```shell= sdkmanager --list_installed ``` > ![](https://i.imgur.com/YUGoPqm.png) ## Appendix & FAQ :::info ::: ###### tags: `Android 工具`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully