Rendering issues: Failed to instantiate class: - android.support.v4.widget.DrawerLayout

I am a beginner and am trying to develop an android app. I used the following tutorial and everything is fine (i.e. error / red icon). http://developer.android.com/training/implementing-navigation/nav-drawer.html

However, the following error occurs in the activity xml file: The following classes could not be generated: - android.support.v4.widget.DrawerLayout (Open Class, Show Exception)

I have searched google and Stack Overflow. Found a similar question, however no one answered for them. Assuming someone else ran into the same problem and was able to solve it.

Note. I am using Android-Studio.

Activty.xml have the following flow:

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout" ...........
tools:context=".MyActivity">

    <FrameLayout
        android:id="@+id/content_frame"........
        android:layout_alignParentEnd="true">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </FrameLayout>

    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"........
        android:background="#111"/>

    </android.support.v4.widget.DrawerLayout>

      

+3


source to share


5 answers


The problem is that you are probably using a lower minSdkVersion. I had the same problem: I set minSdkVersion to 14, changed it to 17 (in build.gradle) and rendered it correctly.



+3


source


I had the same problem! just try changing the preview from "android" version to version 4.4.2 (small android) and it will fix the problem :)



0


source


From http://developer.android.com/training/implementing-navigation/nav-drawer.html :

This tutorial describes how to implement a navigation drawer using the DrawerLayout APIs available in the support library.

Are you sure you linked the Support Library correctly ?

0


source


Try this: Under the "Preview" tab, AndroidStudio gives you some options, just hit "Clear Cache" and the XML file should look great.

0


source


I solved this issue when installing additional platform components by following these steps:

Click on the menu "Tools → Android → SDK Manager".

Then click on Appearance and Behavior → System Settings → Android SDK.

On the SDK Platforms tab, check all of the options above (including) "Android 4.0.3 (IceCreamSandwich)".

Click "Apply", wait until finished and ready!

Hope it helps.

0


source







All Articles