Android Question B4xdrawer example error

SayCheese

Member
Licensed User
As a newbee to B4A, Java and Android programming even running a example file can be frustrating even after hours trying to figure out where I did something wrong in the installation process. I'm trying the B4Xdrawer example provided in [B4X] B4XDrawer - sliding drawer.

I did the following:
  • Added the B4XDrawer.bas module
  • Added the library AppCompat (although the "AppCompat with ToolBar" example didn't work either, so the errors probably are related to AppCompat).
  • Added libraries ViewsEx v1.30+ and XUI v1.90.
Compiling is oke but running in DBug mode I got this error:

** Activity (main) Create, isFirst = true **
Error occurred on line: 217 (B4XDrawer)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:292)
at b4a.example.main._activity_create(main.java:391)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)

Line 217 is from the example project
B4X:
Public Sub getCenterPanel As B4XView
    Return mCenterPanel
End Sub
Any help is appreciated.
 

SayCheese

Member
Licensed User
"As is" means just open the example project and hit F5?
No it fails to run with the error although is compiles.
 

SayCheese

Member
Licensed User
Btw without the appcompat library it does not compile. So at least I think I have to install this library?
 

Erel

Administrator
Staff member
Licensed User

SayCheese

Member
Licensed User
Yes I'm using the v9.30.

It seems that I'm missing some library I'm not aware of. I don't know how to get them although I have tried to struggle with the information the SDKmanager provides.

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 349)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:292)
at b4a.example.main._activity_create(main.java:349)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6694)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/Toolbar;
at b4a.example.main._globals(main.java:411)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.example.main.initializeGlobals(main.java:320)
at b4a.example.main.afterFirstLayout(main.java:101)
... 9 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.Toolbar" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/b4a.example-LO8UogOVgVkS6G9dS7WqJA==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-LO8UogOVgVkS6G9dS7WqJA==/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 14 more
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 

SayCheese

Member
Licensed User
B4A Version: 9.30
Java Version: 8
Parsing code. (0.01s)
Building folders structure. (0.07s)
Compiling code. (0.04s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. (0.00s)
Compiling generated Java code. (0.07s)
Convert byte code - optimized dex. (1.89s)
Packaging files. (1.90s)
Copying libraries resources (0.00s)
Signing package file (debug key). (1.48s)
ZipAlign file. (0.16s)
Installing file to device. (4.02s)
Device serial: 53ea683d0305
Completed successfully.
 

SayCheese

Member
Licensed User
Installed AppCompatv4.0

upload_2019-8-12_16-15-42.png


Ran Jetifier and cleaned the project.....still no succes.

Copying updated assets files (3)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 217 (B4XDrawer)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:292)
at b4a.example.main._activity_create(main.java:391)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6694)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)


at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 19 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/Toolbar;
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:624)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:611)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:366)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.initializeGlobals(main.java:320)
at b4a.example.main.afterFirstLayout(main.java:101)
... 9 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.Toolbar" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/b4a.example-9UdHONTNSNfqBW5yP-sCrg==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-9UdHONTNSNfqBW5yP-sCrg==/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 20 more
** Activity (main) Resume **

What about the error
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.Toolbar" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/b4a.example-9UdHONTNSNfqBW5yP-sCrg==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-9UdHONTNSNfqBW5yP-sCrg==/lib/arm64, /system/lib64, /vendor/lib64]]
 

SayCheese

Member
Licensed User
Yes, I read them and changed the locations of both the Additional libraries and Shared Folder.
This time it ran without any problems.

You gentlemen have both been very patient. Thank you for your help.

If I may do a suggestion:
If the Jetifier runs into an error (because of the bad locations of the 2 read only folders) perhaps it's a good idea to let the user know. I Only saw a window popping up for a split second. I didn't know what to expect from the jetifier so I assumed this was oke.
 
Top