升级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' }//阿里云国内镜像
错误:➜ Test git:(develop) ✗ react-native link
rnpm-install info Linking react-native-os ios dependency
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'buildConfigurationList' of undefined
Please file an issue here: https://github.com/facebook/react-native/issues
Cannot read property 'buildConfigurationList' of undefined
TypeError: Cannot read property 'buildConfigurationList' of undefined
at /Users/dongliyun/okcoin/OKWallet/node_modules/react-native/local-cli/link/ios/getTargets.js:18:68
at Array.map (<anonymous>)
at getTargets (/Users/dongliyun/okcoin/OKWallet/node_modules/react-native/local-cli/link/ios/getTargets.js:16:18)
at registerNativeModuleIOS (/Users/dongliyun/okcoin/OKWallet/node_modules/react-native/local-cli/link/ios/registerNativeModule.js:52:19)
at Object.registerNativeModule [as register] (/Users/dongliyun/okcoin/OKWallet/node_modules/react-native/local-cli/link/ios/common/registerNativeModule.js:15:5)
at Object.keys.forEach.platform (/Users/dongliyun/okcoin/OKWallet/node_modules/react-native/local-cli/link/link.js:74:16)
at Array.forEach (<anonymous>)
at linkDependency (/Users/dongliyun/okcoin/OKWallet/node_modules/react-native/local-cli/link/link.js:44:32)
at <anonymous>
解决方法:
错误:
解决:
https://github.com/facebook/react-native/pull/25146/files#diff-263fc157dfce55895cdc16495b55d190
在下面文件加一句:RCTReadString(input, "__attribute__((__unused__))") ||