ingsaurabh ingsaurabh - 3 months ago 58
Android Question

ClassNotFoundException: Didn't find class "android.support.design.R$styleable"

Hi I am using NavigationView but I am getting error, below is my xml, I have already included android support and v7 library

project.properties as I am not using Android studio

target=android-22
android.library.reference.1=../android-support-v7-appcompat
android.library.reference.2=../design


<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.toxic.apps.kodi" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:minHeight="?attr/actionBarSize" />

<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

<android.support.design.widget.NavigationView
android:id="@+id/navigation"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:itemTextColor="@color/primary"
app:menu="@menu/drawer" />

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


and below is my stacktrace

06-21 06:24:12.799: E/AndroidRuntime(4913): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.toxic.apps.kodi/com.toxic.apps.kodi.Activities.MainActivity}: android.view.InflateException: Binary XML file line #30: Error inflating class android.support.design.widget.NavigationView
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.app.ActivityThread.access$800(ActivityThread.java:144)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.os.Handler.dispatchMessage(Handler.java:102)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.os.Looper.loop(Looper.java:135)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.app.ActivityThread.main(ActivityThread.java:5221)
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.reflect.Method.invoke(Native Method)
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.reflect.Method.invoke(Method.java:372)
06-21 06:24:12.799: E/AndroidRuntime(4913): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
06-21 06:24:12.799: E/AndroidRuntime(4913): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
06-21 06:24:12.799: E/AndroidRuntime(4913): Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class android.support.design.widget.NavigationView
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.view.LayoutInflater.createView(LayoutInflater.java:633)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
06-21 06:24:12.799: E/AndroidRuntime(4913): at com.toxic.apps.kodi.Activities.AbstractBaseActivity.setContentView(AbstractBaseActivity.java:33)
06-21 06:24:12.799: E/AndroidRuntime(4913): at com.toxic.apps.kodi.Activities.MainActivity.onCreate(MainActivity.java:35)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.app.Activity.performCreate(Activity.java:5933)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
06-21 06:24:12.799: E/AndroidRuntime(4913): ... 10 more
06-21 06:24:12.799: E/AndroidRuntime(4913): Caused by: java.lang.reflect.InvocationTargetException
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.reflect.Constructor.newInstance(Native Method)
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.view.LayoutInflater.createView(LayoutInflater.java:607)
06-21 06:24:12.799: E/AndroidRuntime(4913): ... 22 more
06-21 06:24:12.799: E/AndroidRuntime(4913): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.support.design.internal.ScrimInsetsFrameLayout.<init>(ScrimInsetsFrameLayout.java:54)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.support.design.widget.NavigationView.<init>(NavigationView.java:92)
06-21 06:24:12.799: E/AndroidRuntime(4913): at android.support.design.widget.NavigationView.<init>(NavigationView.java:88)
06-21 06:24:12.799: E/AndroidRuntime(4913): ... 25 more
06-21 06:24:12.799: E/AndroidRuntime(4913): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.R$styleable" on path: DexPathList[[zip file "/data/app/com.toxic.apps.kodi-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
06-21 06:24:12.799: E/AndroidRuntime(4913): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
06-21 06:24:12.799: E/AndroidRuntime(4913): ... 28 more
06-21 06:24:12.799: E/AndroidRuntime(4913): Suppressed: java.lang.ClassNotFoundException: android.support.design.R$styleable
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.Class.classForName(Native Method)
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
06-21 06:24:12.799: E/AndroidRuntime(4913): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
06-21 06:24:12.799: E/AndroidRuntime(4913): ... 29 more
06-21 06:24:12.799: E/AndroidRuntime(4913): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

Answer

Ok finally I solved the problem using Denis Loh suggestion. Key to solve this problem is check the R file of all the included libraries, when this crash happens design library R is not generated and hence not shown in gen folder of your project.

But eclipse will not show you problem why it is not generated(God knows how eclipse work)

So in order to generate R file of design folder

In project.properties of design library set target to 21 or highest available

Clean v7 , design and your project run & enjoy