来自androidx和com.android.support的重复类 [英] Duplicate classes from androidx and com.android.support
问题描述
我最近更新了Android Studio(并且我非常确定Gradle版本),现在在尝试编译项目时遇到了很多错误.这是目前困扰我的人:
I recently updated my Android Studio (and I'm pretty sure the Gradle version), and now I've been getting a bunch of errors when trying to compile my project. Here's the one that is plaguing me at the moment:
Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:26.1.0)
其次是很多类似的东西.
This is followed by lots of similar ones.
我尝试删除对com.android.support
的所有使用以支持androidx(请参见此处 (因为我使用的是替换对象),但是即使删除了库,仍在使用com.android.support
库(一旦尝试再次编译它们,它们就会被重新制作).
I tried removing all uses of com.android.support
in favor of androidx (see here for what I was using the replace things), but com.android.support
libraries are still being used, even when I delete the libraries (they're just remade once I try to compile again).
这是指向我收到的完整错误的链接.
Here's a link to the full error I get.
推荐答案
将这些行添加到gradle.properties
:
android.useAndroidX=true
android.enableJetifier=true
如果没有gradle.properties
,请在项目的根目录中创建文件.
If gradle.properties
is absent, create the file in the root directory of your project.
看起来您的依赖项中的任何地方都有一些support
遗物,也许来自lib?要调查并查看依赖关系树,请运行:
It looks like you have some support
relics anywhere in your dependencies, maybe from a lib? To investigate and see the dependencies tree, please run:
./gradlew :yourApp:dependencies
然后您会从那里看到它.
and then you see from where it comes.
这篇关于来自androidx和com.android.support的重复类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!