Flutter 环境配置遇到的问题
2023-01-28 本文已影响0人
希尔罗斯沃德_董
1、Unable to find bundled Java version
/// 如果没有jre文件夹就手动创建一个
cd /Users/username/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
flutter doctor -v
2、 ✗ HTTP host "https://cloud.google.com/" is not reachable
HTTP Host availability check is taking a long time...[!] HTTP Host Availability
✗ HTTP host "https://maven.google.com/" is not reachable. Reason: An error
occurred while checking the HTTP host: Operation timed out
✗ HTTP host "https://cloud.google.com/" is not reachable. Reason: An error
occurred while checking the HTTP host: Operation timed out
解决:
删除缓存 :Flutter SDK路径/flutter/bin/cache
进入
Flutter SDK路径/flutter/packages/flutter_tools/lib/src/http_host_validator.dart
/// Android specific required HTTP hosts.
List<String> androidRequiredHttpHosts(Platform platform) {
return <String>[
// If kEnvCloudUrl is set, it will be used as the maven host
if (!platform.environment.containsKey(kEnvCloudUrl))
'https://maven.google.com',
];
}
改成:
/// Android specific required HTTP hosts.
List<String> androidRequiredHttpHosts(Platform platform) {
return <String>[
// If kEnvCloudUrl is set, it will be used as the maven host
if (!platform.environment.containsKey(kEnvCloudUrl))
'https://dl.google.com/dl/',
];
}
再将 kPubDevHttpHost 和 kgCloudHttpHost 两个常量 分别修改为 https://pub.flutter-io.cn/ 和 https://storage.flutter-io.cn/(解决第二个)
const String kPubDevHttpHost = 'https://pub.flutter-io.cn/';
const String kgCloudHttpHost = 'https://storage.flutter-io.cn/';