升級Flutter
Git 地址 https://github.com/flutter/flutter
錯誤:
➜ setup_namer flutter upgrade
Your flutter checkout has local changes that would be erased by upgrading. If you want to keep these changes, it is recommended
that you stash them via "git stash" or else commit the changes to a local branch. If it is okay to remove local changes, then
re-run this command with --force.
解決方法:
flutter upgrade --force
➜ setup_namer flutter upgrade --force
Upgrading Flutter from /Users/dongliyun/flutter/flutter...
error: The following untracked working tree files would be overwritten by merge:
.github/lock.yml
dev/benchmarks/macrobenchmarks/assets/999x1000.png
dev/benchmarks/macrobenchmarks/lib/src/animated_placeholder.dart
dev/benchmarks/macrobenchmarks/lib/src/color_filter_and_fade.dart
dev/benchmarks/macrobenchmarks/lib/src/large_images.dart
dev/benchmarks/macrobenchmarks/lib/src/post_backdrop_filter.dart
dev/benchmarks/macrobenchmarks/lib/src/text.dart
dev/benchmarks/macrobenchmarks/lib/src/web/bench_build_material_checkbox.dart
dev/benchmarks/macrobenchmarks/lib/src/web/bench_card_infinite_scroll.dart
dev/benchmarks/macrobenchmarks/lib/src/web/bench_draw_rect.dart
dev/benchmarks/macrobenchmarks/lib/src/web/bench_dynamic_clip_on_static_picture.dart
dev/benchmarks/macrobenchmarks/lib/src/web/bench_simple_lazy_text_scroll.dart
dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart
dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_out_of_picture_bounds.dart
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
dev/benchmarks/macrobenchmarks/lib/src/web/test_data.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
dev/benchmarks/macrobenchmarks/macos/.gitignore
dev/benchmarks/macrobenchmarks/macos/Runner.xcodeproj/project.pbxproj
dev/benchmarks/macrobenchmarks/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
dev/benchmarks/macrobenchmarks/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
dev/benchmarks/macrobenchmarks/macos/Runner.xcworkspace/contents.xcworkspacedata
dev/benchmarks/macrobenchmarks/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
dev/benchmarks/macrobenchmarks/macos/Runner/AppDelegate.swift
dev/benchmarks/macrobenchmarks/macos/Runner/Base.lproj/MainMenu.xib
dev/benchmarks/macrobenchmarks/macos/Runner/Configs/AppInfo.xcconfig
dev/benchmarks/macrobenchmarks/macos/Runner/Configs/Debug.xcconfig
dev/benchmarks/macrobenchmarks/macos/Runner/Configs/Release.xcconfig
dev/benchmarks/macrobenchmarks/macos/Runner/Configs/Warnings.xcconfig
dev/benchmarks/macrobenchmarks/macos/Runner/DebugProfile.entitlements
dev/benchmarks/macrobenchmarks/macos/Runner/Info.plist
dev/benchmarks/macrobenchmarks/macos/Runner/MainFlutterWindow.swift
dev/benchmarks/macrobenchmarks/macos/Runner/Release.entitlements
dev/benchmarks/macrobenchmarks/test_driver/animated_placeholder_perf.dart
dev/benchmarks/macrobenchmarks/test_driver/animated_placeholder_perf_test.dart
dev/benchmarks/macrobenchmarks/test_driver/color_filter_and_fade_perf.dart
dev/benchmarks/macrobenchmarks/test_driver/color_filter_and_fade_perf_test.dart
dev/benchmarks/macrobenchmarks/test_driver/post_backdrop_filter_perf.dart
dev/benchmarks/macrobenchmarks/test_driver/post_backdrop_filter_perf_test.dart
dev/benchmarks/macrobenchmarks/test_driver/textfield_perf.dart
dev/benchmarks/macrobenchmarks/test_driver/textfield_perf_test.dart
dev/benchmarks/macrobenchmarks/test_memory/large_images.dart
dev/benchmarks/macrobenchmarks/web/index.html
dev/benchmarks/microbenchmarks/lib/geometry/curves_bench.dart
dev/benchmarks/platform_views_layout/README.md
dev/benchmarks/platform_views_layout/android/app/build.gradle
dev/benchmarks/platform_views_layout/android/app/src/main/AndroidManifest.xml
dev/benchmarks/platform_views_layout/android/app/src/main/java/dev/bechmarks/platform_views_layout/DummyPlatformView.java
dev/benchmarks/platform_views_layout/android/app/src/main/java/dev/bechmarks/platform_views_layout/DummyPlatformViewActivity.java
dev/benchmarks/platform_views_layout/android/app/src/main/java/dev/bechmarks/platform_views_layout/DummyPlatformViewFactory.java
dev/benchmarks/platform_views_layout/android/build.gradle
dev/benchmarks/platform_views_layout/android/gradle.properties
dev/benchmarks/platform_views_layout/android/gradle/wrapper/gradle-wrapper.properties
dev/benchmarks/platform_views_layout/android/settings.gradle
dev/benchmarks/platform_views_layout/ios/Flutter/AppFrameworkInfo.plist
dev/benchmarks/platform_views_layout/ios/Flutter/Flutter.xcconfig
d
Aborting
Updating cf37c2cd0..e6b34c2b5
此方法不行,乾脆從官網下來了flutter包
錯誤:
flutter doctor --android-licenses
出現錯誤:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
解決方法:降級到jdk8.
➜ flutter_app java --version
查看當前自己所用jdk版本,從官網https://www.oracle.com/java/technologies/javase-jdk8-downloads.html 下,但是需要賬號登錄。我下載下來放在了 這裏
下載下來後雙擊安裝
在 Terminal 運行
➜ flutter_app where java
/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/java
/usr/bin/java
打開 /Library/Java/JavaVirtualMachines/ 會看到文件 jdk1.8.0_251.jdk
➜ flutter_app vim ~/.bash_profile
將 jdk8添加到環境配置
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
export JAVA_14_HOME=/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home
export JAVA_HOME=$JAVA_8_HOME
export PATH=$JAVA_HOME/bin:$PATH
export CLASS_PATH=$JAVA_HOME/lib:$CLASS_PATH
然後運行
➜ flutter_app source ~/.bash_profile
再次運行
➜ flutter_app where java
/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/bin/java
/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/java
/usr/bin/java
➜ flutter_app java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
看到當前使用的jdk版本是1.8.0_251
再次運行
➜ flutter_app flutter doctor --android-licenses
會出現
flutter_app flutter doctor --android-licenses
Warning: File /Users/xx/.android/repositories.cfg could not be loaded.
1 of 7 SDK package license not accepted.] 100% Computing updates...
Review license that has not been accepted (y/N)?
輸入y,之後一路 y就行,最後會顯示
All SDK package licenses accepted
完成!
錯誤:
在Android studio 中 flutter run 報錯
➜ 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...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
Required by:
project :app
> Skipped due to earlier error
> Skipped due to earlier error
> Skipped due to earlier error
> Could not resolve io.flutter:x86_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
Required by:
project :app
> Skipped due to earlier error
> Skipped due to earlier error
> Skipped due to earlier error
> Could not resolve io.flutter:x86_64_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
Required by:
project :app
> Skipped due to earlier error
> Skipped due to earlier error
> Skipped due to earlier error
* 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 1m 53s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 114.4s
Exception: Gradle task assembleDebug failed with exit code 1
解決方法:
錯誤:
在Android模擬器運行時報錯:
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4.
Required by:
project :app
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4.
> Could not parse POM http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4/flutter_embedding_debug-1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4.pom
> Content is not allowed in prolog.
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4.
> Could not parse POM http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4/flutter_embedding_debug-1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4.pom
> Content is not allowed in prolog.
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4.
> Could not parse POM http://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4/flutter_embedding_debug-1.0.0-e4f46f32f1fd00872bf19e226ba43ef71e4a84a4.pom
> Content is not allowed in prolog.
* 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 38s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
解決方法:
maven { url 'https://maven.aliyun.com/repository/google' }//阿里雲國內鏡像
maven { url 'https://maven.aliyun.com/repository/jcenter' }//阿里雲國內鏡像