版权声明
- 本文原创作者:谷哥的小弟
- 作者博客地址:http://blog.csdn.net/lfdfhl
概述
新版Android Studio在添加依赖时报错:
Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward. The IDE can help with this: Refactor > Migrate to AndroidX... less... (Ctrl+F1)
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible
报错原因:
1、由于Android Studio 版本较高,添加库依赖已经不支持compile语句,应使用implementation或者api.
2、若使用api或implementation语句仍然报错,可能是库的版本较低,出现了不兼容的现象。
3、由于原来的support 库太乱了,谷歌在新版本中取消了support库,使用了新的andriodX库。
迁移到 AndroidX
为了解决上述问题,我们需要将原理的support库迁移到AndroidX并使用implementation添加依赖。详细步骤如下: