gpt4 book ai didi

android - 未找到类 "androidx.constraintlayout.ConstraintLayout"

转载 作者:行者123 更新时间:2023-12-05 00:16:36 26 4
gpt4 key购买 nike

我正在开发一个 Android 库,这个库有一些布局 Activity 。

在布局中,我有下一个代码

...
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.google.android.material.floatingactionbutton.FloatingActionButton
...

我正在使用 Androidx。

我收到以下错误:

Error inflating class android.support.constraint.ConstraintLayout

解决此问题的第一次尝试是将android.support.constraint.ConstraintLayout更改为androidx.constraintlayout.widget.ConstraintLayout

但是当我这样做时,我收到以下错误:

androidx.constraintlayout.widget.ConstraintLayout cannot be cast to androidx.constraintlayout.widget.Group

所以我尝试更改为androidx.constraintlayout.widget.Group

我收到以下错误:

androidx.constraintlayout.widget.Group cannot be cast to android.view.ViewGroup

我再次对 androidx 进行了重构,然后收到以下错误:

Didn't find class "androidx.constraintlayout.ConstraintLayout"

有什么想法吗?

谢谢

最佳答案

按照此步骤操作

First add below dependencies in your Build.Gradle file

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

Use this ConstraintLayout like this

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</androidx.constraintlayout.widget.ConstraintLayout>

Make sure you have correct imports of ConstraintLayout for in your activity if you have used

import androidx.constraintlayout.widget.ConstraintLayout

关于android - 未找到类 "androidx.constraintlayout.ConstraintLayout",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57903216/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com