0

I just copied some code into my layout file from a tutorial project I was using to learn. However now my activity_main is unable to render properly. This is the error:

enter image description here

This is layout code:

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:id="@+id/coordinatorLayout"
    tools:context="com.xxxxxx.eventmanager.MainActivity">

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

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

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

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/fragment"
        android:name="MainActivityFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout="@layout/fragment_main" />


    <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.support.design.widget.CoordinatorLayout>
user3718908x100
  • 7,939
  • 15
  • 64
  • 123

2 Answers2

0

did you add a compile 'com.android.support:design:22.2.0' to your dependencies?

if yes, maybe this helps you: The following classes could not be instantiated: - android.support.v7.widget.Toolbar

Community
  • 1
  • 1
yital9
  • 6,544
  • 15
  • 41
  • 54
0

So i switched from com.android.support:design:23.2.0 to com.android.support:design:23.1.1 and it worked. Still works for me. Did the same for compile com.android.support:appcompat-v7:23.2.0 and com.android.support:support-v4:23.2.0

user3718908x100
  • 7,939
  • 15
  • 64
  • 123