来自 androidx 和 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)
接下来是很多类似的.
我尝试删除 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.