即使未在 android 项目中启用,也会出现 Androidx 库问题 [英] Getting Androidx library issue even though its not enabled in android project

查看:40
本文介绍了即使未在 android 项目中启用,也会出现 Androidx 库问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个问题

This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.

The following AndroidX dependencies are detected: androidx.annotation:annotation:1.1.0

我不断收到此错误,我一直在网上搜索以找出问题所在,但找不到任何内容

I keep getting this error and I have been searching the internet to figure out what is wrong and I cannot find anything

"而且我不能在我的项目中使用 Androidx 库 "

"And I can't use Androidx library in my project "

推荐答案

在关于此问题的许多 SO 答案中,已建议添加 exclude 'META-INF/DEPENDENCIES' 和其他一些排除项.然而,这些都不适合我.在我的情况下,场景是这样的:

In many of the answers on SO on this problem it has been suggested to add exclude 'META-INF/DEPENDENCIES' and some other excludes. However none of these worked for me. In my case scenario was like this:

我在依赖中添加了这个:

I had added this in dependancies:

implementation 'androidx.annotation:annotation:1.1.0'

而且我还在 gradle.properties 中添加了这个:

And also I had added this in gradle.properties:

android.useAndroidX=true

我已经添加了这两个,因为我收到构建错误找不到符号类 Nullable",并且有人建议将其作为解决此问题的一些答案(例如此处)

Both of these I had added, because I was getting build error 'cannot find symbol class Nullable' and it was suggested as solution to this on some of answers like here

然而,最终我遇到了错误:

However, eventually I landed up in getting error:

 More than one file was found with OS independent path 'androidsupportmultidexversion.txt'

没有排除对我有用.最后我删除了

No exclude was working for me. Finally I just removed

implementation 'androidx.annotation:annotation:1.1.0'

来自 build.grdle 文件.最后我摆脱了这个

from build.grdle file. and finally I got rid of this

( 找到不止一个文件与操作系统无关的路径 'androidsupportmultidexversion.txt' )

"More than one file was found with OS..." build error.

我浪费了我的时间.但没有找到解决方案.然后我只是改变我的项目

I wasted hours of mine.But didn't found solution of this. Then i just change my project

minSdkVersion 19 

 minSdkVersion 21 

最后我可以毫无错误地构建我的 apk 文件

And finally i am able to build my apk file without any error

这篇关于即使未在 android 项目中启用,也会出现 Androidx 库问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆