如何使用最新的gardle版本编译第一个flutter应用程序

时间:2019-07-12 21:50:08

标签: android gradle flutter

我使用android studio创建了一个新的flutter应用程序(在Windows 10上),我尝试运行创建的项目,但gradlew.bat异常退出。

在更新flutter之后,我无法编译任何项目。 我尝试使用android studio和flutter运行的line命令进行编译。

我尝试更改distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

在gardle-wrapper.properties中,但没有任何变化。

低于android studio上的日志错误

Finished with error: ProcessException: Process "D:\FlutterApps\flutter_app2\android\gradlew.bat" exited abnormally:
Exception in thread "main" java.io.FileNotFoundException: C:\Program Files\Android\Android Studio\gradle\gradle-5.1.1\bin\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip.lck (Impossibile trovare il percorso specificato)
    at java.io.RandomAccessFile.open0(Native Method)
    at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:49)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
  Command: D:\FlutterApps\flutter_app2\android\gradlew.bat -v


**and the log error with flutter line command**





ProcessException: ProcessException: Process "D:\FlutterApps\flutter_app2\android\gradlew.bat" exited abnormally:
Exception in thread "main" java.io.FileNotFoundException: C:\Program Files\Android\Android Studio\gradle\gradle-5.1.1\bin\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip.lck (Impossibile trovare il percorso specificato)
    at java.io.RandomAccessFile.open0(Native Method)
    at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:49)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
  Command: D:\FlutterApps\flutter_app2\android\gradlew.bat -v

```
#0      runCheckedAsync (package:flutter_tools/src/base/process.dart:259:7)
<asynchronous suspension>
#1      _initializeGradle (package:flutter_tools/src/android/gradle.dart:225:9)
<asynchronous suspension>
#2      _ensureGradle (package:flutter_tools/src/android/gradle.dart:206:37)
<asynchronous suspension>
#3      _readGradleProject (package:flutter_tools/src/android/gradle.dart:134:31)
<asynchronous suspension>
#4      _gradleProject (package:flutter_tools/src/android/gradle.dart:111:34)
<asynchronous suspension>
#5      getGradleAppOut (package:flutter_tools/src/android/gradle.dart:105:29)
<asynchronous suspension>
#6      AndroidApk.fromAndroidProject (package:flutter_tools/src/application_package.dart:160:23)
<asynchronous suspension>
#7      ApplicationPackageFactory.getPackageForPlatform (package:flutter_tools/src/application_package.dart:47:32)
<asynchronous suspension>
#8      FlutterDevice.runHot (package:flutter_tools/src/resident_runner.dart:352:56)
<asynchronous suspension>
#9      HotRunner.run (package:flutter_tools/src/run_hot.dart:251:39)
<asynchronous suspension>
#10     RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:469:37)
<asynchronous suspension>
#11     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:478:18)
<asynchronous suspension>
#12     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:383:33)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#14     _rootRun (dart:async/zone.dart:1124:13)
#15     _CustomZone.run (dart:async/zone.dart:1021:19)
#16     _runZoned (dart:async/zone.dart:1516:10)
#17     runZoned (dart:async/zone.dart:1463:12)
#18     AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#19     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:375:20)
#20     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
<asynchronous suspension>
#21     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:396:21)
<asynchronous suspension>
#22     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#23     _rootRun (dart:async/zone.dart:1124:13)
#24     _CustomZone.run (dart:async/zone.dart:1021:19)
#25     _runZoned (dart:async/zone.dart:1516:10)
#26     runZoned (dart:async/zone.dart:1463:12)
#27     AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#28     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:356:19)
<asynchronous suspension>
#29     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#30     new Future.sync (dart:async/future.dart:224:31)
#31     CommandRunner.run (package:args/command_runner.dart:112:14)
#32     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:242:18)
#33     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:22)
<asynchronous suspension>
#34     _rootRun (dart:async/zone.dart:1124:13)
#35     _CustomZone.run (dart:async/zone.dart:1021:19)
#36     _runZoned (dart:async/zone.dart:1516:10)
#37     runZoned (dart:async/zone.dart:1500:12)
#38     run.<anonymous closure> (package:flutter_tools/runner.dart:60:18)
<asynchronous suspension>
#39     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#40     _rootRun (dart:async/zone.dart:1124:13)
#41     _CustomZone.run (dart:async/zone.dart:1021:19)
#42     _runZoned (dart:async/zone.dart:1516:10)
#43     runZoned (dart:async/zone.dart:1463:12)
#44     AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#45     runInContext (package:flutter_tools/src/context_runner.dart:56:24)
<asynchronous suspension>
#46     run (package:flutter_tools/runner.dart:51:10)
#47     main (package:flutter_tools/executable.dart:62:9)
<asynchronous suspension>
#48     main (file:///C:/Android/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#49     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#50     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
```

## flutter doctor

```
[32m[✓][39m Flutter (Channel beta, v1.7.8+hotfix.3, on Microsoft Windows [Versione 10.0.17134.885], locale it-IT)
    [32m•[39m Flutter version 1.7.8+hotfix.3 at C:\Android\flutter
    [32m•[39m Framework revision b712a172f9 (3 days ago), 2019-07-09 13:14:38 -0700
    [32m•[39m Engine revision 54ad777fd2
    [32m•[39m Dart version 2.4.0

[32m[✓][39m Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [32m•[39m Android SDK at C:\Users\neo\AppData\Local\Android\sdk
    [32m•[39m Android NDK location not configured (optional; useful for native profiling support)
    [32m•[39m Platform android-28, build-tools 28.0.3
    [32m•[39m Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    [32m•[39m Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    [32m•[39m All Android licenses accepted.

[32m[✓][39m Android Studio (version 3.4)
    [32m•[39m Android Studio at C:\Program Files\Android\Android Studio
    [32m•[39m Flutter plugin version 37.0.1
    [32m•[39m Dart plugin version 183.6270
    [32m•[39m Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[32m[✓][39m Connected device (1 available)
    [32m•[39m Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

[32m•[39m No issues found!
```

0 个答案:

没有答案