I am getting an error:No enum constant com.android.manifmerger.AttributeOperationType.CONTEXT. when I am trying to use ConstraintLayout
Here is my xml file:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@ id/inputFirstName"
android:layout_width="398dp"
android:layout_height="47dp"
android:layout_margin="10dp"
android:layout_marginEnd="188dp"
android:layout_marginBottom="21dp"
android:hint="Enter your first name"
android:minHeight="48dp"
app:layout_constraintBottom_toTopOf="@ id/inputLastName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.848" />
<EditText
android:id="@ id/inputLastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="135dp"
android:hint="Enter your last name"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@ id/btnUploadData"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="56dp"
android:layout_marginEnd="8dp"
android:text="@string/save_data"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@ id/inputLastName" />
<Button
android:id="@ id/btnReadData"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="44dp"
android:layout_marginEnd="8dp"
android:text="@string/retrieve_data"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@ id/btnUploadData"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@ id/textViewResultTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginStart="104dp"
android:layout_marginTop="43dp"
android:text="FireStore data :"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@ id/btnReadData" />
<TextView
android:id="@ id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginStart="8dp"
android:layout_marginTop="48dp"
android:text=""
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@ id/textViewResultTitle"
app:layout_constraintVertical_bias="0.081" />
</androidx.constraintlayout.widget.ConstraintLayout>
When I tried to use ConstraintLayout I deleted a and put instead
This is what I found on the forums. It didn't work so I decided to return and put in it "androidx.constraintlayout.widget.ConstraintLayout" but it also gave me an error. So I don't know how to fix it. Maybe it is because of that my xml file is in the manifest folder: enter image description here Here is my dependencies in build.gradle (:app):
build.gradle (:app) File
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}
android {
namespace 'com.example.myapplication'
compileSdk 32
defaultConfig {
applicationId "com.example.myapplication"
minSdk 19
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
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation platform('com.google.firebase:firebase-bom:31.1.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx:24.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// To use constraintlayout in compose
implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")
}
CodePudding user response:
According to your screenshot, you've replaced your AndroidManifest.xml
's contents with layout XML. That file is extremely important and you'll get all kinds of errors if you try to build without a valid one!
You need to revert it and then create a layout file (in the res/layout
folder) for the layout XML you're trying to use