gpt4 book ai didi

android - 无法解析类 android.support.constraint.ConstraintLayout

转载 作者:行者123 更新时间:2023-12-04 23:46:21 27 4
gpt4 key购买 nike

我得到这条红色的线

<android.support.constraint.ConstraintLayout 
和应用程序在打开时崩溃。
它工作正常,但现在出现错误:无法解析类 android.support.constraint.constraintlayout我还尝试将依赖项添加到模块 Gradle 文件中,并尝试通过 (add dependencies on androidx.constraints..,) 链接修复建议的修复程序,但仍然没有运气。我是新来的。请帮忙。
这是主要 Activity 的所有代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="match_parent"
android:background="@drawable/background"
tools:context=".MainActivity">


<Button
android:id="@+id/act1Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="Bill Calculation"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/askOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="What you want to do?"
android:textColor="#00BCD4"
android:textSize="30sp"
app:layout_constraintBottom_toTopOf="@+id/act1Btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/btn3"
android:layout_width="130dp"
android:layout_height="55dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="Tax Calc"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/act1Btn" />

<Button
android:id="@+id/btn4"
android:layout_width="142dp"
android:layout_height="46dp"
android:text="Mobile Tax"
app:layout_constraintBottom_toTopOf="@+id/btn3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/act1Btn" />
</android.support.constraint.ConstraintLayout>

最佳答案

  • 确保您拥有 maven.google.com build.gradle (Project: Name) 中声明的存储库文件:
  • repositories {
    google()
    }
  • 将库添加为 build.gradle (Module: app) 中的依赖项文件:
  • dependencies {
    implementation "androidx.constraintlayout:constraintlayout:2.1.0"
    }
  • 使用 ConstrainLayout写:

  • <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- Your Content Here -->

    </androidx.constraintlayout.widget.ConstraintLayout>

    关于android - 无法解析类 android.support.constraint.ConstraintLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64342158/

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