0

i am having problem, failed to instantiate one or more classes.Following classes cannot be instantiate . android.support.v7.widget.AppCompatTextview

There it is my xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal">

<de.hdodenhof.circleimageview.CircleImageView
    android:id="@+id/iv_comment_owner_display"
    android:layout_width="20dp"
    android:layout_height="20dp"
    android:src="@drawable/facebook" />

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_weight="1"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tv_username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Username"
        android:textColor="@android:color/black"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/tv_comment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:text=""
        android:textColor="@android:color/black" />

</LinearLayout>


</LinearLayout>

4 Answers4

0

AppCompatTextView was added in appcompat-v7:22.1.0

Please check you appcompat version. You have to update your gradle file with this.

Shahinoor Shahin
  • 685
  • 3
  • 14
  • i have latest version of appCompat in gradle com.android.support:appcompat-v7:26.0.2 –  Sep 06 '17 at 05:59
0

clean/Rebuild project from Android Studio,it might help. If it doesn't try to invalidate caches and restart android studio.

himel
  • 500
  • 5
  • 14
0

If you have not done, Try adding the dependencies in your build.gradle(Module:App) please check the version according to your app

dependencies {

compile 'com.android.support:design:25.3.1'

}

Android Geek
  • 8,956
  • 2
  • 21
  • 35
0

Try putting this code in your layout

        <android.support.v7.widget.AppCompatTextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello world"
        android:textSize="18dp"
        />

because i see no AppCompatTextView in your layout.

Android Geek
  • 8,956
  • 2
  • 21
  • 35