android studio list 文件问题

标签 android android-gradle-plugin android-manifest androidx

我在构建项目时遇到错误。好像是androidx和support libraries有冲突,但是项目里没有设置androix。

错误:

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 <application> element at AndroidManifest.xml:27:5-154:19 to override.

参见 http://g.co/androidstudio/manifest-merger有关 list 合并的更多信息。

我的构建 gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "xxxxxxxxxxxxxxxx"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 16
        versionName "2.5"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:support-v13:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.github.yukuku:ambilwarna:2.0.1'
    implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    implementation 'com.wang.avi:library:2.1.3'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.github.warkiz.tickseekbar:tickseekbar:0.1.3'
    implementation 'com.jsibbold:zoomage:1.2.0'
    implementation 'com.google.android.gms:play-services-ads:18.1.1'
    implementation 'com.facebook.android:audience-network-sdk:5.4.1'

}

gradle.proprieties

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decou

pled_projects

# org.gradle.parallel=true

最佳答案

您的一个或多个依赖项似乎正在将 androidx 加载到您的项目中,并且 AndroidX 应该是所有支持库的替代品,你不应该一起使用它们,因为它们会相互覆盖类。看看 AndroidX Doc .

您需要从您的项目中找到并删除正在使用 androidx 的库,或者将其迁移到 androidx。我建议将项目完全迁移到 androidx

这很容易做到,而且支持库已经过时了。而且您会发现 androidx 更易于使用。

关于android studio list 文件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58118119/

相关文章:

android - DexArchiveMergerException : Unable to merge dex - Android Studio 3. 0 稳定

android - 从 list 中以编程方式加载 Activity 和/或应用程序 Logo

android - 如何在景观中获得可用高度?

安卓工作室 3.1 : StackOverflowError when executing task transformClassesWithDexBuilderForDebug when using qoppapdf library

android - Gradle SourceSets 按 productFlavor 和 buildType

java - 如何在 Android 中创建一个无法被 Advanced Task Killer 杀死的服务

android - 拥有多个 Launcher Activity

android - 在android kitkat中刷新画廊

Android TabsAdapter 处理 fragment

android - 在android中的道路上绘制多段线