我正在做布局,在啟動模擬器時出現此錯誤,我試圖清理代碼并重建它,我也已經重新安裝了 android studio。我也試過“無效快取”,但問題仍然存在
我在媒體上讀到您需要洗掉“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);
}
}
這是 build.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'
}
uj5u.com熱心網友回復:
在 bolow 屬性的 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"
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/494804.html
