Java Question Class not included from aar file

corwin42

Expert
Licensed User
Longtime User
I'm trying to create a new wrapper for the Mike Penz MaterialDrawer library.

My wrapper depends on AppCompat library and several *.aar libraries. I have the problem that I get an NoClassDefFoundError. But I'm sure the class is in one of the referenced *.aar files.

main_activity_create (java line: 408)
java.lang.NoClassDefFoundError: com.mikepenz.fastadapter.adapters.HeaderAdapter
at com.mikepenz.materialdrawer.DrawerBuilder.<init>(DrawerBuilder.java:868)
at de.amberhome.objects.materialdrawer.MDDrawerBuilderWrapper.Initialize(MDDrawerBuilderWrapper.java:37)
at de.amberhome.appcompat.toolbarexample1.main._activity_create(main.java:408)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at de.amberhome.appcompat.toolbarexample1.main.afterFirstLayout(main.java:102)
at de.amberhome.appcompat.toolbarexample1.main.access$000(main.java:17)
at de.amberhome.appcompat.toolbarexample1.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
main_activity_create (java line: 408)
java.lang.NoClassDefFoundError: com.mikepenz.fastadapter.adapters.HeaderAdapter
at com.mikepenz.materialdrawer.DrawerBuilder.<init>(DrawerBuilder.java:868)
at de.amberhome.objects.materialdrawer.MDDrawerBuilderWrapper.Initialize(MDDrawerBuilderWrapper.java:37)
at de.amberhome.appcompat.toolbarexample1.main._activity_create(main.java:408)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at de.amberhome.appcompat.toolbarexample1.main.afterFirstLayout(main.java:102)
at de.amberhome.appcompat.toolbarexample1.main.access$000(main.java:17)
at de.amberhome.appcompat.toolbarexample1.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I have added the custom libs and a small example project. You will need official AppCompat and XMLLayoutbuilder libraries.

The HeaderAdapter should be in the fastadapter-1.5.5.aar. It seems that it is not included into the apk.

Any ideas?
 

Attachments

  • CustomLibs.zip
    398.3 KB · Views: 373
  • MaterialDrawerExample.zip
    16.9 KB · Views: 317

corwin42

Expert
Licensed User
Longtime User
Where can I find the resources folder?
Damn, I always forget it.

I'm currently not at home. You can take the one from the example from the Material 2 tutorial (using the AppCompat library). You only need to remove the values folder from it.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I ran your program in release mode and got this error:
B4X:
** Activity (main) Create, isFirst = true **
ActionBar Height: 73.5
main_activity_create (java line: 408)
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mikepenz/fastadapter/adapters/ItemAdapter;
   at de.amberhome.objects.materialdrawer.MDDrawerBuilderWrapper.Initialize(MDDrawerBuilderWrapper.java:37)
   at de.amberhome.appcompat.toolbarexample1.main._activity_create(main.java:408)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at de.amberhome.appcompat.toolbarexample1.main.afterFirstLayout(main.java:102)
   at de.amberhome.appcompat.toolbarexample1.main.access$000(main.java:17)
   at de.amberhome.appcompat.toolbarexample1.main$WaitForLayout.run(main.java:80)
   at android.os.Handler.handleCallback(Handler.java:751)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:154)
   at android.app.ActivityThread.main(ActivityThread.java:6044)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mikepenz.fastadapter.adapters.ItemAdapter" on path: DexPathList[[zip file "/data/app/de.amberhome.appcompat.toolbarexample1-2/base.apk"],nativeLibraryDirectories=[/data/app/de.amberhome.appcompat.toolbarexample1-2/lib/arm64, /system/lib64, /vendor/lib64]]
   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
   ... 14 more
   Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mikepenz/fastadapter/AbstractAdapter;
     ... 14 more
   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mikepenz.fastadapter.AbstractAdapter" on path: DexPathList[[zip file "/data/app/de.amberhome.appcompat.toolbarexample1-2/base.apk"],nativeLibraryDirectories=[/data/app/de.amberhome.appcompat.toolbarexample1-2/lib/arm64, /system/lib64, /vendor/lib64]]
     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
     ... 14 more
     Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/RecyclerView$Adapter;
       ... 14 more
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView$Adapter" on path: DexPathList[[zip file "/data/app/de.amberhome.appcompat.toolbarexample1-2/base.apk"],nativeLibraryDirectories=[/data/app/de.amberhome.appcompat.toolbarexample1-2/lib/arm64, /system/lib64, /vendor/lib64]]
       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
       ... 14 more
main_activity_create (java line: 408)
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mikepenz/fastadapter/adapters/ItemAdapter;
   at de.amberhome.objects.materialdrawer.MDDrawerBuilderWrapper.Initialize(MDDrawerBuilderWrapper.java:37)
   at de.amberhome.appcompat.toolbarexample1.main._activity_create(main.java:408)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at de.amberhome.appcompat.toolbarexample1.main.afterFirstLayout(main.java:102)
   at de.amberhome.appcompat.toolbarexample1.main.access$000(main.java:17)
   at de.amberhome.appcompat.toolbarexample1.main$WaitForLayout.run(main.java:80)
   at android.os.Handler.handleCallback(Handler.java:751)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:154)
   at android.app.ActivityThread.main(ActivityThread.java:6044)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mikepenz.fastadapter.adapters.ItemAdapter" on path: DexPathList[[zip file "/data/app/de.amberhome.appcompat.toolbarexample1-2/base.apk"],nativeLibraryDirectories=[/data/app/de.amberhome.appcompat.toolbarexample1-2/lib/arm64, /system/lib64, /vendor/lib64]]
   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
   ... 14 more
   Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mikepenz/fastadapter/AbstractAdapter;
     ... 14 more
   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mikepenz.fastadapter.AbstractAdapter" on path: DexPathList[[zip file "/data/app/de.amberhome.appcompat.toolbarexample1-2/base.apk"],nativeLibraryDirectories=[/data/app/de.amberhome.appcompat.toolbarexample1-2/lib/arm64, /system/lib64, /vendor/lib64]]
     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
     ... 14 more
     Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/RecyclerView$Adapter;
       ... 14 more
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView$Adapter" on path: DexPathList[[zip file "/data/app/de.amberhome.appcompat.toolbarexample1-2/base.apk"],nativeLibraryDirectories=[/data/app/de.amberhome.appcompat.toolbarexample1-2/lib/arm64, /system/lib64, /vendor/lib64]]
       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
       ... 14 more

The important line is: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/RecyclerView$Adapter;

You need to add a dependency on: com.android.support:recyclerview-v7
 

corwin42

Expert
Licensed User
Longtime User
The important line is: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/RecyclerView$Adapter;

You need to add a dependency on: com.android.support:recyclerview-v7

Thanks. Strange thing is that I got a different stacktrace. There was no hint about the missing RecyclerView Adapter. Which device did you use to test it? My test was on a N5 with Android 6.0.1. Maybe I should try an emulator?
 
Top