Android Studio gradle 问题中的 Flutter 项目

Posted

技术标签:

【中文标题】Android Studio gradle 问题中的 Flutter 项目【英文标题】:Flutter project in Android Studio gradle issue 【发布时间】:2019-08-01 10:27:17 【问题描述】:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.1) and runtime (1.0.2) 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.


BUILD FAILED in 5s

*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.

*******************************************************************************************
Finished with error: 
Gradle task assembleDebug failed with exit code 1

【问题讨论】:

【参考方案1】:

在你的build.gradle下面试试

subprojects 
  project.configurations.all 
     resolutionStrategy.eachDependency  it ->
        if (it.requested.group == 'androidx.appcompat'
              && !it.requested.name.contains('appcompat') ) 
           it.useVersion "1.0.2"
        
     
  

或者

androidx.appcompat:appcompat 更改为dependencies 块内的版本1.0.2

【讨论】:

以上是关于Android Studio gradle 问题中的 Flutter 项目的主要内容,如果未能解决你的问题,请参考以下文章

android studio gradle怎么改低

android studio怎么设置gradle版本

android studio更新gradle在哪个目录下

android studio - Gradle 的问题

Android studio 报错问题

Android Studio的Gradle中compileOptions的问题