flutter在iOS平台Run的好好的,在安卓上Run出错,报错信息如下:
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> File 'com.android.builder.files.ZipCentralDirectory@6d707ed5' was deleted, but previous version not found in cache
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> File 'com.android.builder.files.ZipCentralDirectory@10d2360b' was deleted, but previous version not found in cache
* 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 9s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 10.7s
Exception: Gradle task assembleDebug failed with exit code 1
解决:项目/android/build.gradle 中第 9 行
classpath'com.android.tools.build:gradle:3.5.0'
将3.5.0改为最新的3.6.1
修改后保存,Run起来,又报错
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/**/Documents/Flutter学习Demo/NewMyYaoPaiProject/MyYaoPaiProject/android/app/build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.internal.version-check']
> Minimum supported Gradle version is 5.6.4. Current version is 5.6.2. If using the gradle wrapper, try editing the distributionUrl in /Users/**/Documents/Flutter/***/***/android/gradle/wrapper/gradle-wrapper.properties to gradle-5.6.4-all.zip
* 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 4s
这是说:gradle-wrapper.properties中的 distributionUrl 需要将版本号5.6.2改为5.6.4,即在项目\android\gradle\wrapper\gradle-wrapper.properties 文件第6行修改如下:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
再次Run即可成功~