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

查看:742
本文介绍了即使未在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的许多答案中,建议添加排除'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天全站免登陆