總的來說需要的也就4樣東西,找齊了配置一下就OK;
-
Flutter SDK[https://flutter.io/docs/get-started/install/windows] (建議下載官網的,下載完直接能用)
-
下載Dart插件
-
下載Flutter插件
- 配置環境變量
-
準備ide(Androidstudio或者IntelliJ IDEA)配置flutter的SDK即可
遇到的問題:
-
不能下載插件 問題
File->Settings->Apparence & Behavior->System Settings->Updates->use secure connnection 勾去掉
-
文件加載失敗,換阿里鏡像
* Error running Gradle: ProcessException: Process "E:\flutter\demo\flutter_app\android\gradlew.bat" exited abnormally: Starting a Gradle Daemon (subsequent builds will be faster) > Configure project :app 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 'E:\flutter\demo\flutter_app\android\app\build.gradle' line: 26 * What went wrong: A problem occurred evaluating project ':app'. > Could not resolve all artifacts for configuration 'classpath'. > Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.2.0) > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.2.0/kotlin-reflect-1.2.0.jar'. > Could not HEAD 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.2.0/kotlin-reflect-1.2.0.jar'. > Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloudfront.net/13.32.253.234, d29vzk4ow07wi7.cloudfront.net/13.32.253.66, d29vzk4ow07wi7.cloudfront.net/13.32.253.201, d29vzk4ow07wi7.cloudfront.net/13.32.253.237] failed: Read timed out * 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 2m 13s Command: E:\flutter\demo\flutter_app\android\gradlew.bat app:properties Please review your Gradle project setup in the android/ folder.
flutter_app/android/build/gradle中修改文件 repositories { //google() //jcenter() maven{ url 'https://maven.aliyun.com/repository/google' } maven{ url 'https://maven.aliyun.com/repository/jcenter' } maven{url 'http://maven.aliyun.com/nexus/content/groups/public'} } allprojects { repositories { //google() //jcenter() maven{ url 'https://maven.aliyun.com/repository/google' } maven{ url 'https://maven.aliyun.com/repository/jcenter' } maven{url 'http://maven.aliyun.com/nexus/content/groups/public'} } }
在 flutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle這個文件修改一下(或者使用翻牆軟件也行),我就使用一下阿里的鏡像服務器把 buildscript { repositories { //google() //jcenter() maven{ url 'https://maven.aliyun.com/repository/google' } maven{ url 'https://maven.aliyun.com/repository/jcenter' } maven{url 'http://maven.aliyun.com/nexus/content/groups/public'} } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' } }
-
缺少ndk-bundle (https://developer.android.google.cn/ndk/downloads/)
* Error running Gradle: ProcessException: Process "E:\flutter\demo\flutter_app\android\gradlew.bat" exited abnormally: > Configure project :app Checking the license for package Android SDK Platform 27 in C:\Users\kingsoft\AppData\Local\Android\sdk\licenses Warning: License for package Android SDK Platform 27 not accepted. FAILURE: Build failed with an exception. * Where: Build file 'E:\flutter\demo\flutter_app\android\build.gradle' line: 26 * What went wrong: A problem occurred evaluating root project 'android'. > A problem occurred configuring project ':app'. > Failed to install the following Android SDK packages as some licences have not been accepted. platforms;android-27 Android SDK Platform 27 To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager. Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html Using Android SDK: C:\Users\kingsoft\AppData\Local\Android\sdk * 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. E:\flutter\demo\flutter_app>flutter run Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering". Launching lib/main.dart on Android SDK built for x86 in debug mode... Initializing gradle... 0.9s Resolving dependencies... * Error running Gradle: ProcessException: Process "E:\flutter\demo\flutter_app\android\gradlew.bat" exited abnormally: > Configure project :app Checking the license for package Android SDK Platform 27 in C:\Users\kingsoft\AppData\Local\Android\sdk\licenses Warning: License for package Android SDK Platform 27 not accepted. FAILURE: Build failed with an exception. * Where: Build file 'E:\flutter\demo\flutter_app\android\build.gradle' line: 32 * What went wrong: A problem occurred evaluating root project 'android'. > A problem occurred configuring project ':app'. > Failed to install the following Android SDK packages as some licences have not been accepted. platforms;android-27 Android SDK Platform 27 To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager. Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html Using Android SDK: C:\Users\kingsoft\AppData\Local\Android\sdk * 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 9s Command: E:\flutter\demo\flutter_app\android\gradlew.bat app:properties Please review your Gradle project setup in the android/ folder.
-
Build file ‘E:\flutter\project\flutter_app\android\build.gradle’ line: 32
創建一個lib【common】,app:依賴【common】出現該原因
subprojects {
// project.evaluationDependsOn(':app')
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
}
}
}!