- step1: BREW
https://segmentfault.com/a/1190000013317511
(BREW is a package management tool under Mac, similar to yum in centos, it is easy to install / uninstall / update a variety of software packages, such as: nodejs , elasticsearch, kibana, mysql, mongodb etc., can be used to quickly build a variety of local environment, an indispensable tool for programmers) - step2: Flutter SDK package
https://flutter.io/setup-macos/
(remember the address decompression) - step3: the environment variable configuration
terminal type
vim ~/.bash_profile
Type (meaning configure flutter commands can be used anywhere,)
pwd is the address of the download, unzip Flutter
export PATH=/pwd/flutter/bin:$PATH
source
Command to reload it
source ~/.bash_profile
- step4: development environment configuration
check
flutter doctor
If there [!] X flag indicating no detection by the Bank, we need to set up or install the appropriate software
- Android studio installation
http://www.android-studio.org/ - Terminal allows the protocol:
flutter doctor --android-licenses
a down through Y - Other plug according to corresponding mounting
- step5:Android studio
- Configure----->plugin-----> download Flutter
- Tools -------> AVD manager (VM) ------> Create Virtual Device -----> Nexus 5x (optional)
- After the virtual machine is running, click the debug button, and let the program up and running Flutter
- Debug
Error 1:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not download kotlin-compiler-embeddable.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.50)
> Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.3.50/kotlin-compiler-embeddable-1.3.50.jar'.
> Read timed out
Solution:
First, modify build.gradle file in the directory under the android out projects to google () and jcenter () to remove the two lines. Ali instead link
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' }
Second, modify flutter.gradle files under Flutter SDK package, this directory should vary according to the location of your SDK stored.
This step there are two cases
1, flutter.gradle document repositories is google () and jcenter (),
repositories{
google()
gcenter()
}
The Google () and jcenter () to remove the two lines. Ali instead of links.
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' }
2, flutter.gradle document repositories is in this FIG.
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
The repositories are changed
repositories {
maven{
url 'https://maven.aliyun.com/repository/jcenter'
}
maven{
url 'http://maven.aliyun.com/nexus/content/groups/public'
}
}
Debug again after two or more steps, if the same error appeared, then the terminal
vim ~/.bash_profile
Plus two
PUB_HOSTED_URL=https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
No error
Error 2:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
> Failed to transform artifact 'arm64_v8a_debug.jar (io.flutter:arm64_v8a_debug:1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695)' to match attributes {artifactType=android-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: C:\Users\juwuguo\.gradle\caches\modules-2\files-2.1\io.flutter\arm64_v8a_debug\1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695\2ef393f0cfe7b16f75cbb560a12364cc448a62af\arm64_v8a_debug-1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695.jar.
> Failed to transform 'C:\Users\juwuguo\.gradle\caches\modules-2\files-2.1\io.flutter\arm64_v8a_debug\1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695\2ef393f0cfe7b16f75cbb560a12364cc448a62af\arm64_v8a_debug-1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695.jar' using Jetifier. Reason: invalid block type. (Run with --stacktrace for more details.)
> Failed to transform artifact 'x86_64_debug.jar (io.flutter:x86_64_debug:1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695)' to match attributes {artifactType=android-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: C:\Users\juwuguo\.gradle\caches\modules-2\files-2.1\io.flutter\x86_64_debug\1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695\ce0e3fab2c8696e176c54639579d3d438a8a0925\x86_64_debug-1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695.jar.
> Failed to transform 'C:\Users\juwuguo\.gradle\caches\modules-2\files-2.1\io.flutter\x86_64_debug\1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695\ce0e3fab2c8696e176c54639579d3d438a8a0925\x86_64_debug-1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695.jar' using Jetifier. Reason: invalid literal/length code. (Run with --stacktrace for more details.)
Solve:
android studio the Preference -----> Compiler -----> Kotlin Compiler -----> Target changed the JVM Version 1.8 to 1.6