Vazquez0806 Vazquez0806 - 7 months ago 10
Java Question

The following classes couldn't be instantiated

On my homeactivity.xml it says:
The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.FloatingActionButton (Open Class, Show Exception, Clear Cache)

Here is my code



<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#ff4747"
app:popupTheme="@style/PopupOverlay" />


<include layout="@layout/content_home" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"
android:background="#001f9c" />

</android.support.design.widget.AppBarLayout>




I don't know why this happened. Can someone please help?

Answer

as commented you have to include the dependencies for design which is like this, this will be added under the dependencies block of the app module of the build.gradle

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

it should be something like this ..

enter image description here

if the design dependencies is not included in the build.gradle and you try to use mentioned classes in your question you will not be able to render those classes and the error you get in layout would be something like this

enter image description here