AAPT:错误:'0'与属性layout_constraintEnd_toEndOf (attr) 引用|枚举 [parent=0] 不兼容



我正在做布局,当启动模拟器时,我得到了这个错误我试图清理代码并重建它,我已经重新安装了android工作室。我还尝试了"无效缓存";但问题依然存在

我在媒体上看到你需要删除'kotlin-parcelize'

但是它仍然对我不起作用,有人能帮助我吗?我看过他穿中号衣服我应该放,我该怎么做?

xml代码

<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eef4fb"
tools:context=".SplashActivity">
<TextView
android:id="@+id/app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:elevation="2dp"
android:fontFamily="@font/bungee"
android:text="@string/app_name"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="50sp"
app:layout_constraintEnd_toEndOf="0"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintTop_toBottomOf="@+id/lottie" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie"
android:layout_width="300dp"
android:layout_height="300dp"
android:elevation="2dp"
app:layout_constraintBottom_toBottomOf="0"
app:layout_constraintEnd_toEndOf="0"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintTop_toTopOf="0"
app:layout_constraintVertical_bias="0.1"
app:lottie_autoPlay="true"/>
</androidx.constraintlayout.widget.ConstraintLayout>
这是Java文件
package com.allforus.bookclub;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
@SuppressLint("CustomSplashScreen")
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_main);
}
}

这是构建。gradle文件


plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.allforus.bookclub"
minSdk 26
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "com.airbnb.android:lottie:2.8.0"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

在下面的XML文件属性中,使用parent代替0

app:layout_constraintEnd_toEndOf="0"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintBottom_toBottomOf="0"
app:layout_constraintEnd_toEndOf="0"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintTop_toTopOf="0"