Flutter 구축 환경의Gradle Wrapper 다운로드 문제 해결 방법
33071 단어 android
... 에 따라https://flutter.io/혹은https://codelabs.developers.google.com/codelabs/flutter/#1의 단계 구축 환경:
flutter doctor
: 소스 컴파일, 다운로드 의존Building flutter tool...
Downloading Material fonts... 0.7s
Downloading package sky_engine... 0.6s
Downloading common tools... 1.0s
Downloading darwin-x64 tools... 8.3s
Downloading darwin-x64 tools... 8.9s
Downloading android-arm-profile/darwin-x64 tools... 1.8s
Downloading android-arm-release/darwin-x64 tools... 1.0s
Downloading android-x86 tools... 4.1s
Downloading android-x64 tools... 4.2s
Downloading android-arm tools... 2.1s
Downloading android-arm-profile tools... 1.6s
Downloading android-arm-release tools... 1.7s
Downloading ios tools... 6.9s
Downloading ios-profile tools... 5.4s
Downloading ios-release tools... 7.4s
Downloading Gradle Wrapper...
결과는 bin/cache 디렉토리에서 다음과 같이 생성되었습니다.
artifacts
dart-sdk
dart-sdk.stamp
engine.stamp
flutter_tools.snapshot
flutter_tools.stamp
lockfile
material_fonts.stamp
pkg
렉 걸렸어: Downloading Gradle Wrapper...
SocketException: SocketException: Connection failed (OS Error: No route to host, errno = 65), address = android.googlesource.com, port = 443
또는 다른 오류, 어쨌든 원인은android에 연결되지 않았기 때문입니다.googlesource.com(하지만 브라우저는 열 수 있음)
그래서 이 문장들을 찾았다.
https://github.com/getlantern/forum/issues/29 https://github.com/getlantern/lantern/issues/3341 http://www.jianshu.com/p/411a60f415a5
설정(Lantern):
export http_proxy=127.0.0.1:61537
export https_proxy=127.0.0.1:61538
또는 설정:
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=$http_proxy
결과:
curl https://android.googlesource.com/
문제없다
curl https://www.google.com/
오류: Server aborted the SSL handshake.그리고
flutter doctor
여전히 오류 (여전히https://android.googlesource.com/접근할 수 없음;그렇지만https://storage.googleapis.com/flutter_infra/flutter/$version/은(는) 액세스할 수 있습니다.로그를 보려면 다음과 같이 하십시오.
SocketException: SocketException: Connection failed (OS Error: No route to host, errno = 65), address = android.googlesource.com, port = 443
10
11 ```
12 #0 fetchUrl (package:flutter_tools/src/base/net.dart:18)
13
14 #1 _downloadFile (package:flutter_tools/src/cache.dart:408)
15
16 #2 _downloadZippedTarball. (package:flutter_tools/src/cache.dart:424)
17
18 #3 _withTemporaryFile (package:flutter_tools/src/cache.dart:436)
19
20 #4 _downloadZippedTarball (package:flutter_tools/src/cache.dart:423)
21 #5 GradleWrapper.updateInner (package:flutter_tools/src/cache.dart:397)
22
23 #6 CachedArtifact.update (package:flutter_tools/src/cache.dart:223)
24
25 #7 Cache.updateAll (package:flutter_tools/src/cache.dart:196)
26
27 #8 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:225)
28
29 #9 FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:181)
30
31 #10 CommandRunner.runCommand (package:args/command_runner.dart:194)
32
33 #11 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:276)
34
35 #12 CommandRunner.run. (package:args/command_runner.dart:109)
36 #13 new Future.sync (dart:async/future.dart:222)
37 #14 CommandRunner.run (package:args/command_runner.dart:109)
38 #15 FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:161)
39 #16 run. (package:flutter_tools/executable.dart:143)
40
41 #17 AppContext._run (package:flutter_tools/src/base/context.dart:76)
42
43 #18 AppContext.runInZone. (package:flutter_tools/src/base/context.dart:66)
44 #19 _rootRun (dart:async/zone.dart:1120)
45 #20 _CustomZone.run (dart:async/zone.dart:1001)
46 #21 runZoned (dart:async/zone.dart:1467)
47 #22 AppContext.runInZone (package:flutter_tools/src/base/context.dart:65)
48 #23 run (package:flutter_tools/executable.dart:114)
소스 파일 수정: packages/fluttertools/lib/src/cache.dart:
bool isUpToDate() {
//////////////////////////////////////// log ////////////////////////////////////////
var stamp = cache.getStampFor(name);
// logger.writeToStdOut
logger.writeToStdOut('
==============isUpToDate? location, version, getStampFor: ');
logger.writeToStdOut('
name: ');
logger.writeToStdOut( name );
logger.writeToStdOut('
location: ');
logger.writeToStdOut( location.path );
logger.writeToStdOut('
version: ');
logger.writeToStdOut( version );
logger.writeToStdOut('
stamp: ');
logger.writeToStdOut( stamp);
logger.writeToStdOut('
');
//////////////////////////////////////////// log ////////////////////////////////////
if (!location.existsSync()) {
// ,
logger.writeToStdOut('
location not exists');
return false;
}
if (version != cache.getStampFor(name)) {
// , version stamp( ) version ,
logger.writeToStdOut('
Stamp not match');
return false;
}
//
return isUpToDateInner();
}
/// Download a file from the given [url] and write it to [location].
Future _downloadFile(Uri url, File location) async {
_ensureExists(location.parent);
//////////////////////////////////////////// log ////////////////////////////////////
logger.writeToStdOut('
_downloadFile path : ' + location.path);
//////////////////////////////////////////// log ////////////////////////////////////
final List<int> fileBytes = await fetchUrl(url);
location.writeAsBytesSync(fileBytes, flush: true);
}
/// Download a zip archive from the given [url] and unzip it to [location].
Future _downloadZipArchive(Uri url, Directory location) {
//////////////////////////////////////////// log ////////////////////////////////////
logger.writeToStdOut('
_downloadZip : ' + location.path);
//////////////////////////////////////////// log ////////////////////////////////////
return _withTemporaryFile('download.zip', (File tempFile) async {
await _downloadFile(url, tempFile);
_ensureExists(location);
os.unzip(tempFile, location);
});
}
/// Download a gzipped tarball from the given [url] and unpack it to [location].
Future _downloadZippedTarball(Uri url, Directory location) {
//////////////////////////////////////////// log ////////////////////////////////////
logger.writeToStdOut('
_downloadZipped:' + location.path);
//////////////////////////////////////////// log ////////////////////////////////////
return _withTemporaryFile('download.tgz', (File tempFile) async {
await _downloadFile(url, tempFile);
_ensureExists(location);
os.unpack(tempFile, location);
});
}
몇 가지 수정을 했는데 그 안의 논리가 매우 간단하다는 것을 발견했다.
Future updateAll() async {
if (!_lockEnabled)
return null;
for (CachedArtifact artifact in _artifacts) {
if (!artifact.isUpToDate())
// ,
await artifact.update();
}
}
artifact.업데이트 안의 논리는 파일이 존재하는지, 버전이 일치하는지 확인하고, 조건이 충족되면 업데이트하지 않아도 되고, 그렇지 않으면 다운로드할 수 없다는 것이다.다운로드의 논리는 임시 디렉터리에 다운로드한 다음bin/cache에 압축을 풀고 xxx를 만드는 것이다.stamp 파일은 버전 번호를 기록합니다.
그리고bin/cache 디렉터리에 있는 flutter 삭제tools.stamp 및 fluttertools.snapshot, 다시 실행
flutter doctor
:==============isUpToDate? location, version, getStampFor:
name: material_fonts
location: /Users/wangshenglong/flutter/bin/cache/artifacts/material_fonts
version: https://storage.googleapis.com/flutter_infra/flutter/fonts/13ac995daa9dda0a6ba0a45f1fccc541e616a74c/fonts.zip
stamp: https://storage.googleapis.com/flutter_infra/flutter/fonts/13ac995daa9dda0a6ba0a45f1fccc541e616a74c/fonts.zip
==============isUpToDate? location, version, getStampFor:
name: engine
location: /Users/wangshenglong/flutter/bin/cache/artifacts/engine
version: 31d03de019794a4b0e3c98c04cf7be501fb962fb
stamp: 31d03de019794a4b0e3c98c04cf7be501fb962fb
==============isUpToDate? location, version, getStampFor:
name: gradle_wrapper
location: /Users/wangshenglong/flutter/bin/cache/artifacts/gradle_wrapper
version: 0b5c1398d1d04ac245a310de98825cb7b3278e2a
stamp: null
Downloading Gradle Wrapper...https://android.googlesource.com/platform/tools/base/+archive/0b5c1398d1d04ac245a310de98825cb7b3278e2a/templates/gradle/wrapper.tgz -
_downloadZipped:/Users/wangshenglong/flutter/bin/cache/artifacts/gradle_wrapper
_downloadFile path : /var/folders/qx/yr3zc94x2sbf16ptpv5v5_tr0000gn/T/7XQy4z/download.tgz
따라서 문제 해결은 간단합니다.
1. https://android.googlesource.com/platform/tools/base/+archive/0b5c1398d1d04ac245a310de98825cb7b3278e2a/templates/gradle/wrapper.tgz, flutter/bin/cache/artifacts/gradle_wrapper
;
2. flutter/bin/cache/ gradle_wrapper.stamp , 0b5c1398d1d04ac245a310de98825cb7b3278e2a。 。
flutter doctor를 다시 실행하려면:
==============isUpToDate? location, version, getStampFor:
name: material_fonts
location: /Users/wangshenglong/flutter/bin/cache/artifacts/material_fonts
version: https://storage.googleapis.com/flutter_infra/flutter/fonts/13ac995daa9dda0a6ba0a45f1fccc541e616a74c/fonts.zip
stamp: https://storage.googleapis.com/flutter_infra/flutter/fonts/13ac995daa9dda0a6ba0a45f1fccc541e616a74c/fonts.zip
==============isUpToDate? location, version, getStampFor:
name: engine
location: /Users/wangshenglong/flutter/bin/cache/artifacts/engine
version: 31d03de019794a4b0e3c98c04cf7be501fb962fb
stamp: 31d03de019794a4b0e3c98c04cf7be501fb962fb
==============isUpToDate? location, version, getStampFor:
name: gradle_wrapper
location: /Users/wangshenglong/flutter/bin/cache/artifacts/gradle_wrapper
version: 0b5c1398d1d04ac245a310de98825cb7b3278e2a
stamp: 0b5c1398d1d04ac245a310de98825cb7b3278e2a
[✓] Flutter (on Mac OS X 10.11.2 15C50, locale zh-Hans, channel alpha)
• Flutter at /Users/wangshenglong/flutter
• Framework revision 701d534ba9 (7 days ago), 2017-09-12 14:01:51 -0700
• Engine revision 31d03de019
• Tools Dart version 1.25.0-dev.11.0
[✓] Android toolchain - develop for Android devices (Android SDK 25.0.3)
• Android SDK at /Users/wangshenglong/Documents/DevSoftware/Android_Studio
• Platform android-25, build-tools 25.0.3
• ANDROID_HOME = /Users/wangshenglong/Documents/DevSoftware/Android_Studio
• Java binary at: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
[-] iOS toolchain - develop for iOS devices (Xcode 7.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 7.3, Build version 7D175
✗ Flutter requires a minimum Xcode version of 8.0.0.
Download the latest version or update via the Mac App Store.
✗ libimobiledevice and ideviceinstaller are not installed or require updating. To update, run:
brew uninstall --ignore-dependencies libimobiledevice
brew install --HEAD libimobiledevice
brew install ideviceinstaller
✗ ios-deploy not installed. To install:
brew install ios-deploy
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.io/platform-plugins
To install:
brew install cocoapods
pod setup
[✗] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.io/setup/#android-setup for detailed instructions).
[✓] IntelliJ IDEA Ultimate Edition (version 2017.2.4)
• Flutter plugin version 17.0
• Dart plugin version 172.4155.35
[✓] Connected devices
• Samsung Galaxy S6, 6 0 0, API 23, 1440x2560 • 192.168.62.101:5555 • android-x86 • Android 6.0 (API 23)
큰 성과를 거두다.
부록:
1.logger의 사용법은 나도 모르지만packages/fluttertools/lib/src/base/logger.dart는 원본 파일이 있기 때문에 사용법을 알 수 있습니다: print Error, print Status, write To StdOut, print Trace, start Progress.
2.File.path 나도 몰라. 그래서 구글, 찾았어.https://www.dartlang.org/dart-vm/dart-by-example,api를 찾아보면 알 수 있습니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Kotlin의 기초 - 2부지난 글에서는 Kotlin이 무엇인지, Kotlin의 특징, Kotlin에서 변수 및 데이터 유형을 선언하는 방법과 같은 Kotlin의 기본 개념에 대해 배웠습니다. 유형 변환은 데이터 변수의 한 유형을 다른 데이터...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.