簡體   English   中英

無法定位 android SDK for flutter 醫生

[英]Unable to locate android SDK for flutter doctor

我已經嘗試在我的計算機上卸載並重新安裝 flutter 兩次,但是每當我在終端中運行flutter doctor時,我仍然會遇到以下錯誤。

[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
  Install Android Studio from:
  https://developer.android.com/studio/index.html
  On first launch it will assist you in installing the Android SDK
  components.
  (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
  for detailed instructions).
  If the Android SDK has been installed to a custom location, set
  ANDROID_SDK_ROOT to that location.
  You may also want to add it to your PATH environment variable.

有誰知道如何解決這個問題? 另外,這可能是我的模擬器都沒有運行我的應用程序的原因嗎? 謝謝,抱歉,我還是 Flutter 和 android 工作室的新手。

如果找不到你的Android SDK,原因可能是你的Android ZF20E3C5E5E54C0AB3D36AZF6的路徑沒有更新到日期。

我認為您的問題與此類似: https://github.com/flutter/flutter/issues/45007

嘗試flutter config --android-sdk <path-to-your-android-sdk-path>來更新 Android SDK 路徑。

此問題與環境變量有關。

輸入環境變量后,必須點擊系統變量,找到“Path”變量。

雙擊“路徑”變量並在右側添加一個新變量。

有兩個目錄需要添加,“D:\AndroidSDK\platforms”和“D:\AndroidSDK\platform-tools”。

這兩個目錄可以在不同的地方,記住這一點。

當我將 android 工作室移動到我的 MacBook 上的外部硬盤驅動器時遇到了同樣的問題,這是我修復的步驟

1 設置安卓 sdk 路徑 flutter config --android-sdk 示例:flutter config --android-sdk /Volumes/Apps/Library/Android

完成后,它顯示另一個錯誤:Android 許可證狀態未知。 要解決這個問題,我們需要添加 andriod studio 目錄,即 android studio app。 像這樣: flutter 配置 --android-studio-dir 示例: flutter 配置 --android-studio-dir /Volumes/Apps/Android\ Studio.app

最后使用以下命令訪問 android 工作室的許可,您就完成了。 flutter 醫生 --android-licenses

例如,如果您這樣做:

flutter config --android-sdk C:\Users\User\AppData\Local\Android\Sdk

什么也沒發生,你必須像這樣加雙反斜杠是正常的:

flutter config --android-sdk C:\\Users\\User\\AppData\\Local\\Android\\Sdk

對於 flutter 10.2.3 和 Android Studio Bumblebee,我不得不使用卸載 sdk

文件 -> 設置 > 外觀和行為 -> 系統設置 -> Android SDK > SDK 平台 > 取消選中所有並應用。

卸載后,我手動刪除了 Android SDK 位置的剩余內容。

然后重新安裝

文件 -> 設置 > 外觀和行為 -> 系統設置 -> Android SDK > SDK 平台 > 檢查 Android API 32 -> 應用

在 SDK Tools tab -> 展開 Android SDK Build Tools -> 32.0.0 and Android Command Line tools (latest)

然后設置

flutter config --android-sdk “你的 sdk root 路徑”

根據我的經驗,flutter 醫生報告了一個問題並且未能找到 Android sdk(即使指定了 sdk 路徑flutter config --android-sdk ),如果安裝的任何平台或構建工具存在問題。

在我的例子中,缺少適用於我的平台的正確build-tools ,並且在使用 sdkmanager 安裝它之后,與sdkmanager醫生中的 sdk 路徑相關的問題也消失了。

我的工作 android sdk 配置(基於 Android 平台 30)是:

  Path                 | Version | Description                    | Location            
  -------              | ------- | -------                        | -------             
  build-tools;30.0.3   | 30.0.3  | Android SDK Build-Tools 30.0.3 | build-tools/30.0.3  
  emulator             | 31.3.11 | Android Emulator               | emulator            
  patcher;v4           | 1       | SDK Patch Applier v4           | patcher/v4          
  platform-tools       | 33.0.3  | Android SDK Platform-Tools     | platform-tools      
  platforms;android-30 | 3       | Android SDK Platform 30        | platforms/android-30

希望這可以幫助遇到同樣問題的任何人,將正確的路徑設置為 android sdk

為了更清楚地了解如何添加路徑

運行此以添加到路徑,

flutter config --android-sdk "path to your sdk root"

例子

flutter config --android-sdk "/Users/clovisokonkwo/androidSdk"

然后這是接受許可

flutter doctor --android-licenses

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM