Home > Back-end >  AAPT: error: '0' is incompatible with attribute layout_constraintEnd_toEndOf (attr) refere
AAPT: error: '0' is incompatible with attribute layout_constraintEnd_toEndOf (attr) refere

Time:06-23

I was doing the layout and when starting the emulator I got this error I tried to clean the code and rebuild it also I already reinstalled the android studio. Also I tried "Invalidate Caches" but the problem still exists

I read on the medium that you need to remove 'kotlin-parcelize'

but still it didn't work for me, can someone help me. i have seen im in medium that's I supposed to put , what I should to do?

This is the xml code

<?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>

This is the Java file

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);
    }
}

This is the build.gradle file


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'
}

CodePudding user response:

in the xml file in bolow properties , use parent instead of 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"
  • Related