Flutter 填坑記錄篇


 1、前言

之前寫了一篇文章關於 flutter 初體驗的一篇,https://www.cnblogs.com/niceyoo/p/9240359.html,當時一頓騷操作,然后程序就跑起來了。

隔了好一段時間,換了個電腦,重新裝了個AndroidStudio,繼續搭建 Flutter ,然后哐哧哐哧用了一會就把需要配置弄好了,然后用 AS 創建了個項目,好家伙,直接報錯。

Launching lib\main.dart on ONEPLUS A5010 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
Exit code 1 from: F:\android_studio_workspace\flutter_app2\flutter_app2\android\gradlew.bat app:properties:
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 E:\AndroidSDK\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.


Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\android_studio_workspace\flutter_app2\flutter_app2\android\app\build.gradle' line: 25

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all files for configuration 'classpath'.
> Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

Finished with error: Please review your Gradle project setup in the android/ folder.

2、問題分析

先看最后一條信息:

finished with error: please review your gradle project setup in the android/ folder.

說,讓我檢查 gradle,然后各種找,發現沒錯啊。

還是從第一條錯誤開始看吧:

NDK is missing a "platforms" directory. If you are using NDK, verify the ndk_  ......

好家伙,這又是個什么鬼.

NDK缺少一個“platforms”目錄。如果您正在使用NDK,請驗證NDK。將dir設置為有效的NDK目錄。
目前它被設置為D: AndroidSDK\ndk-bundle。
如果不使用NDK,請從ANDROID_NDK_HOME或local中卸載NDK變量。屬性刪除此警告。

2.1 解決第一個問題

既然說少了就裝個吧。

下載鏈接:https://developer.android.google.cn/ndk/downloads/

 下載,解壓zip文件 得到一個 android-ndk-rXXb 的文件夾,直接解壓,然后把該文件夾下的所有文件都移動到你的,sdk,ndk-bundle 文件夾下。

再配置個環境變量,重啟 AS 解決問題。

2.2 解決第二個問題

Build file 'F:\android_studio_workspace\flutter_app2\flutter_app2\android\app\build.gradle' line: 25

找到 flutter SDK 路徑下的 \flutter\packages\flutter_tools\gradle\flutter.gradle 文件。

把 gradle 版本改低一點。

 

 博客地址:https://www.cnblogs.com/niceyoo


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM