运行新的Flutter安装时出错

时间:2019-11-15 17:56:00

标签: flutter

我从稳定频道(在Linux上为v1.9.1 + hotfix.6),Android SDK版本29.0.2和Android Studio版本3.5使用Flutter。在Ubuntu 18.4上。设置所有必需的PATH。

医生摘要显示没有问题。

当我运行“ flutter build”时,出现错误:

Initializing gradle...                                             
Resolving dependencies...                                               
* Error running Gradle:
ProcessException: Process "/.../flutter/raw/android/gradlew" exited abnormally:
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to
/.../android-sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.


BUILD FAILED

Total time: 7.627 secs

Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.
    at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
    at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:558)
    ...
    ...
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

FAILURE: Build failed with an exception.

* Where:
Script '/.../flutter/packages/flutter_tools/gradle/flutter.gradle' line: 27

* What went wrong:
A problem occurred evaluating script.
> Could not find method google() for arguments [] on repository container.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  Command: /... /flutter/raw/android/gradlew app:properties


Please review your Gradle project setup in the android/ folder.

如何解决此问题?

2 个答案:

答案 0 :(得分:1)

似乎NDK不在您的PATH上,或者项目在错误的位置查找。 首先确认您已安装NDK/。

Install NDK

勾选此框。 enter image description here

如果确实安装了NDK,则需要更改项目结构以指向正确的位置。 Project Structure

答案 1 :(得分:1)

根据 https://github.com/flutter/flutter/issues/53657#issuecomment-795808016,现在推荐的解决方案是将您的 gradle 版本简单地升级到 4.1.2 或更高版本。

classpath 'com.android.tools.build:gradle:4.1.2'