运行Flutter应用程序时出现此问题
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-v4' has different
version for the compile (26.1.0) and runtime (27.1.1) classpath. You
should manually set the same version via DependencyResolution
* 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 0s
我试图通过添加
解决它subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
但这不起作用
完成错误:Gradle任务assembleDebug失败,退出代码为1
答案 0 :(得分:0)
删除项目主路径中的android
文件夹,然后重新安装应用程序。
android
文件夹将再次创建。此解决方案解决了flutter项目中gradle
的大部分问题。也许可以帮上忙。
答案 1 :(得分:0)
Android依赖项'com.android.support:support-v4'具有不同 版本(用于编译(26.1.0)和运行时(27.1.1)类路径)。因此,您必须更新为相同版本。