错误信息
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
/Users/LinkinStar/flutterProject/xxxxxxxxx/android/app/src/debug/AndroidManifest.xml:22:18-91 Error:
Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:11:5-34:19 to override.
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:11:5-34:19 to override.
我判断问题是由于AndroidX和Android support 共存导致
在更新一些依赖之后出现
Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution
最终解决
在build.gradle文件中添加
中间subprojects这一段
buildscript {
repositories {
google()
jcenter()
} dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
} subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
} if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}
}
}
}
}
参考:https://github.com/flutter/flutter/issues/27254
作者:LinkinStar
未经允许,不得转载