Reputation: 239
I'm getting the following error on LogCat when I try to build and run the app. In my app I've used Cardview to display the edittext and textview. When I try to run the app, it shows me the following error:
Attribute "xmlns:card_view" was already specified for element "android.support.v7.widget.CardView".
It's only displaying this information and it's not even showing me the exact location where the problem is.
Here's the XML which contains the CardView:
activity_basic_info:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="@dimen/_46sdp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:layout_marginTop="@dimen/_8sdp"
android:src="@drawable/ic_arrow_back_black_24dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_centerInParent="true"
android:textSize="@dimen/_16sdp"
android:text="@string/basic_info_header"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:background="@android:color/white"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:layout_marginTop="@dimen/_30sdp"
android:src="@drawable/contact_info"
android:layout_marginStart="@dimen/_40sdp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/_8sdp"
android:layout_marginTop="@dimen/_34sdp"
android:text="@string/contact_info_text"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="@dimen/_12sdp"/>
</LinearLayout>
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_25sdp"
android:layout_marginEnd="@dimen/_25sdp"
android:layout_marginTop="@dimen/_25sdp"
app:cardCornerRadius="@dimen/_10sdp"
app:cardElevation="@dimen/_10sdp">
<LinearLayout
android:background="@drawable/bg_layout"
android:layout_width="match_parent"
android:paddingBottom="@dimen/_2sdp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="@dimen/_15sdp"
android:paddingTop="@dimen/_15sdp"
android:paddingEnd="@dimen/_10sdp"
android:gravity="end"
android:textColor="@android:color/white"
android:background="@color/colorPrimary"
android:text="Name"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingTop="@dimen/_15sdp"
android:paddingStart="@dimen/_10sdp"
android:paddingBottom="@dimen/_15sdp"
android:background="@android:color/transparent"
android:hint="First and Last name"
android:textSize="@dimen/_10sdp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#e2e2e2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="@dimen/_15sdp"
android:paddingTop="@dimen/_15sdp"
android:paddingEnd="@dimen/_10sdp"
android:gravity="end"
android:textColor="@android:color/white"
android:background="@color/colorPrimary"
android:text="Email"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingTop="@dimen/_15sdp"
android:paddingStart="@dimen/_10sdp"
android:paddingBottom="@dimen/_15sdp"
android:background="@android:color/transparent"
android:hint="Email Address"
android:textSize="@dimen/_10sdp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#e2e2e2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="@dimen/_15sdp"
android:paddingTop="@dimen/_15sdp"
android:paddingEnd="@dimen/_10sdp"
android:gravity="end"
android:textColor="@android:color/white"
android:background="@color/colorPrimary"
android:text="Phone"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingTop="@dimen/_15sdp"
android:paddingStart="@dimen/_10sdp"
android:paddingBottom="@dimen/_15sdp"
android:background="@android:color/transparent"
android:hint="Phone Number"
android:textSize="@dimen/_10sdp"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/_1sdp"
android:layout_marginTop="@dimen/_20sdp"
android:layout_marginStart="@dimen/_20sdp"
android:layout_marginEnd="@dimen/_20sdp"
android:background="#bababa"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
My build.gradle :
apply plugin: 'com.android.application'
android {
dataBinding
{
enabled = true
}
compileSdkVersion 28
defaultConfig {
applicationId "com.example.newproject"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
//noinspection GradleDependency
implementation 'com.android.support:support-v4:28.0.0-alpha1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//rest services
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
//design
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
//image binding
implementation 'com.squareup.picasso:picasso:2.71828'
//design libraries
implementation 'com.android.support:design:28.0.0'
//reactive programming
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
//data binding
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.lifecycle:livedata:1.1.1'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
implementation 'android.arch.lifecycle:viewmodel:1.1.1'
//sdp library
implementation 'com.intuit.sdp:sdp-android:1.0.3'
implementation 'com.android.support:design:28.0.0'
//circle image Viewer
implementation 'de.hdodenhof:circleimageview:3.0.0'
}
I have already tried:
Clean Project
Rebuild Project
Invalidate caches and restarted the android studio.
But nothing worked out.
Upvotes: 1
Views: 3308
Reputation: 1
It means tags is already defined in parent which you are using again in child.
Upvotes: 0
Reputation: 41
I ran into a similar issue. To fix it, I just removed the layout_width and layout_height of the global layout of my xml file.
Upvotes: 4