当前位置: 首页 > 知识库问答 >
问题:

flutter找不到Android SDK

蒲昀
2023-03-14

我已经通过AUR安装了flutter。我还安装了aur/android-sdk 26.0.2-1。当我运行flutter run时,我得到:

Warning! This package referenced a Flutter repository via the .packages file that is
no longer available. The repository from which the 'flutter' tool is currently
executing will be used instead.
  running Flutter tool: /home/dair/.flutter-sdk
  previous reference  : /home/dair/flutter
This can happen if you deleted or moved your copy of the Flutter repository, or
if it was on a volume that is no longer mounted or has been mounted at a
different location. Please check your system path to verify that you are running
the expected version (run 'flutter --version' to see which flutter is on your path).

Unable to locate a development device; please run 'flutter doctor' for information about installing additional components.

首先,运行flutter--version,并收到:

Flutter • channel alpha • https://github.com/flutter/flutter.git
Framework • revision e2f54df5ab (9 days ago) • 2017-06-02 10:43:54 -0700
Engine • revision 1f2aa07571
Tools • Dart 1.24.0-dev.3.0

不知道“看哪一个扑在你的路上”到底是什么意思。接下来我运行flutter doctor并得到:

[✓] Flutter (on Linux, locale en_US.UTF-8, channel alpha)
    • Flutter at /home/christopher/.flutter-sdk
    • Framework revision e2f54df5ab (9 days ago), 2017-06-02 10:43:54 -0700
    • Engine revision 1f2aa07571
    • Tools Dart version 1.24.0-dev.3.0

[✗] Android toolchain - develop for Android devices
    ✗ ANDROID_HOME = /opt/android-sdk
      but Android SDK not found at this location.

[✓] Android Studio (version 2.3)
    • Android Studio at /usr/local/android-studio
    • Gradle version 3.2
    • Java version: OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] Connected devices
    • None

但是,如果我cd到/opt/android-sdk中,我会得到:

➜  ~ cd /opt/android-sdk 
➜  android-sdk ls
add-ons  build-tools  emulator  platforms  tools

共有1个答案

关学
2023-03-14

当我尝试flutter doctor命令时,也遇到了同样的问题:

问题很明显,它的发生是因为flutter没有为您的Android SDK创建路径。

解决方法有两种:

或者永远保存它,用Android sdk路径导出android_home

我通过在我的机器上导出android_home来解决这个问题(Arch Linux,但这适用于任何Unix实例)。

这将解决您的问题,但您可能还需要sdkplatform-toolstoolsndk-build路径(当然,需要首先安装所有内容)到我的配置文件(在我的情况下是.zshrc文件,您的.bashrc等文件上也可以这样做):

#SDK exporting - this will solve your issue
export ANDROID_HOME=/home/{user}/Android/Sdk 

#Tools exporting - it can be need in your case
export PATH=/home/{user}/Android/Sdk/platform-tools:$PATH
export PATH=/home/{user}/Android/Sdk/tools:$PATH
export PATH=/home/{user}/Android/ndk-build:$PATH

#Flutter binary exporting
export PATH=/home/{user}/flutter/bin:$PATH

然后,我重新加载了我的配置文件(我的配置文件是.zshrc文件,在您的情况下使用您的文件。例如.bashrc):

source ~/.zshrc

之后,flutter doctor运行正常。

 类似资料:
  • 这就是错误- 在/users/chetan/.pub-cache/hosted/pub.dartlang.org/webview_flutter-1.0.7/iOS/classes/javascriptchannelhandler.m:5://users/chetan/.pub-cache/hosted/pub.dartlang.org/webview_flutter-1.0.7/iOS/clas

  • 我在 iOS (Cocoapods) 中通过 pubspec.yaml 文件对 Flutter 依赖项有一些问题。我可以使用 Flutter 演示默认程序复制问题并将这些依赖项复制到 pubspec.yaml 文件中。 cupertino_icons: ^0.1.2 http: ^0.12.0 4 fl_chart: ^0.10.0 flutter_spinkit: “^4.1.1” flutte

  • 找不到目标文件“lib/main.dart”。 为什么会发生这种情况,我如何解决这个问题?

  • > 错误:执行任务“:Shared_Preferences:VerifyReleaseResources”失败。 工作者引发了1个异常:com.Android.builder.internal.aapt.v2.aapt2异常:Android资源链接失败 d:\my-flutter-app\build\shared_preference\intermediates\res\merged\releas

  • 我正在尝试按照本教程在flutter中设置谷歌地图,但我遇到了一些问题。我的应用程序运行,但我看到一个白色屏幕,没有发生任何事情,并且将以下错误打印到终端: 这很奇怪,因为我的看起来像这样: 这正是错误所要求的,所以我不知道出了什么问题。我查看了其他线程,并做了一些建议,比如运行删除应用程序、并重试,这也不起作用。 这些是我在 我还想添加,但是我得到了以下错误 我也尝试了一些其他版本,但我一直出错

  • 错误:评估项目':app'时出现问题。 无法解析配置“classpath”的所有项目。找不到aapt2-proto.jar(com.android.tools.build:aapt2-proto:0.3.1).在以下位置进行了搜索:https://jcenter.bintray.com/com/android/tools/build/aapt2-proto/0.3.1/aapt2-proto-0.