Android中使用AndroidX出现 but the 'android.useAndroidX' property is not enabled的问题解决办法

    当更新了Android Studio之后编译出现了这样的问题: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.0.1

图片如下:

Android中使用AndroidX出现 but the 'android.useAndroidX' property is not enabled的问题解决办法

    图中显示问题(the 'android.useAndroidX' property is not enabled),即说明了使用了AndroidX的依赖,但是并没有在gradle.properties文件中使能,so,只需要在gradle.properties文件中加上如下两句即可:

android.useAndroidX=true
android.enableJetifier=true

Android中使用AndroidX出现 but the 'android.useAndroidX' property is not enabled的问题解决办法