简体   繁体   English

无法在构建 gradle 文件中实现支持设计库

[英]cannot implement support design library in build gradle file

I'm trying to use Coordinator Layout in my xml file and found that it's corresponding libraries doesn't exists.我试图在我的 xml 文件中使用 Coordinator Layout,发现它对应的库不存在。

So i tried to include this in my gradle build file所以我试图将它包含在我的 gradle 构建文件中

implementation 'com.android.support:design:28.0.0'实施“com.android.support:design:28.0.0”

but it's giving the error但它给出了错误

Supplied String module notation 'androidx.'提供字符串模块符号“androidx.” is invalid.是无效的。 Example notations: > 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'.示例符号:> 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'。

Then i found all support libraries is deprecated and one need to use androidx library.然后我发现所有支持库都已弃用,需要使用 androidx 库。

How to include this library in my gradle file?如何在我的 gradle 文件中包含这个库? ***My main intention is to use Coordinator Layout in my UI

Click on "Refactor" on the android studio menu bar.单击 android 工作室菜单栏上的“重构”。 Select "Migrate to Androidx..." Select “迁移到 Androidx...”

Job Done.任务完成。

You are correct in saying that the support libraries have been deprecated.您说支持库已被弃用是正确的。 The new standard is AndroidX.新标准是 AndroidX。 Here is a link that shows the current mappings from the old support libraries to AndroidX. 是一个链接,显示了从旧支持库到 AndroidX 的当前映射。

Specifically for CoordinatorLayout, it has gone from com.android.support:coordinatorlayout to androidx.coordinatorlayout:coordinatorlayout专门针对 CoordinatorLayout,它已从com.android.support:coordinatorlayout变为androidx.coordinatorlayout:coordinatorlayout

Furthermore, I suggest reading this page about migrating to AndroidX.此外,我建议阅读有关迁移到 AndroidX 的页面 It offers a lot of information and will make your transition to AndroidX much smoother.它提供了大量信息,可以让您更顺畅地过渡到 AndroidX。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 添加Android设计支持库后,Gradle构建速度非常慢 - Gradle build is very slow after adding Android Design Support library 为什么我不能在 build.gradle 中实现设计库 - Why cant i implement design library in build.gradle Android Studio Gradle无法找到'com.android.support:design:22.2.0'(Android设计支持库) - Android Studio Gradle cannot find 'com.android.support:design:22.2.0' (the Android Design Support Library) Android Gradle构建和支持库 - Android gradle build and the support library Android设计支持和其他库给出了gradle构建错误:“ headerLayout”已经定义 - Android design support and other library give gradle build error: “headerLayout” has already been defined 在支持设计库中找不到符号类 - cannot find symbol class in support design library 使用支持库失败构建的Android build.gradle - Android build.gradle using Support Library Failing Build 添加android支持设计库后出现Gradle错误 - Gradle error after add android support design library Android设计支持库-版本号和Gradle错误 - Android design support library - version number and gradle error 无法构建库项目Bintray Gradle - ClassNotFoundException - Cannot build library project Bintray Gradle - ClassNotFoundException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM