Android Question Error: No static field navdrawer_layout of type I in class Lanywheresoftware/b4a/objects/R$layout

JohnC

Expert
Licensed User
Longtime User
I just upgrade from B4A 9.01 to 11.5 and for a big project I ran into the following issues.

Notes:
The app is not a B4Xpages app (and can not be converted due to size)
The app is using #AdditionalJar: com.android.support:support-v4

1) Got errors during compile due to libs not being jetified. I jetified them, and still no good.
But after exiting the IDE, then rerunning it, the libraries then update and dexed and the app fully compiled.

2) But then the compiled app crashes without any "filtered" error, so I unfiltered it and the error was "java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/arch/core/executor/ArchTaskExecutor;".
Added "#AdditionalJar: androidx.arch.core:core-runtime" to project and this error went away.

3) Now I am getting the below filtered error and can not find any hits in the forum:
B4X:
*** Service (starter) Create ***
19:49:13.567: Starter_Service_Created
** Activity (main) Create, isFirst = true **
19:49:13.621: Activity_Create
main_activity_create (java line: 488)
java.lang.NoSuchFieldError: No static field navdrawer_layout of type I in class Lanywheresoftware/b4a/objects/R$layout; or its superclasses (declaration of 'anywheresoftware.b4a.objects.R$layout' appears in base.apk!classes4.dex)
    at de.amberhome.objects.NavigationDrawerWrapper.Initialize2(NavigationDrawerWrapper.java:74)
    at com.omnisoft.voiceit.main._activity_create(main.java:488)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at com.omnisoft.voiceit.main.afterFirstLayout(main.java:105)
    at com.omnisoft.voiceit.main.access$000(main.java:17)
    at com.omnisoft.voiceit.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Any ideas?
 

drgottjr

Expert
Licensed User
Longtime User
did you see this:

this looks like a pretty old library (not that that helps your cause). the author is still active on the forum. maybe he has a thought.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
OK, I shortened my search phrase and found these threads:


This stinks because it was SOOO easy to add a menu item with a simple line of code:
B4X:
NavDrawer.NavigationView.Menu.AddWithGroup2(3, 10,  5, "Settings", SetMenuIcon(Chr(0xF013),False,24))

But with B4XDrawer, now it looks like I can't have a single menu item with a bitmap without spending a bunch of time messing with the designer to create a layout. :mad:

(thanks @drgottjr - I got you reply just before posting this)
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
OK, I got it working!

1) Did the hack from this post (using v2.32 of the DesignSupport lib and only modified the DesignSupport.aar file, not the designsupport.androidx.aar file):
2) Jetifyied the library + exited the IDE
3) Compiled and was getting a runtime error "java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/emoji2/viewsintegration/EmojiTextViewHelper;". Added the four lines from this post: https://www.b4x.com/android/forum/t...-error-and-force-close-app.161362/post-990264

Whola!
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
OK, So I just upgraded from B4A 11.5 to 13 and now I get this error:
B4X:
android.view.InflateException: Binary XML file line #16 in com.omnisoft.voiceit:layout/navdrawer_layout: Binary XML file line #16 in com.omnisoft.voiceit:layout/navdrawer_layout: Error inflating class com.google.android.material.navigation.NavigationView
I need to use the DSNavigationDrawer because I don't have time to rewrite the whole drawer to use the B4XDrawer.

So, if the Hack I mentioned in my previous post got the DSNavigationDrawer to run without an error for B4A 11.5, why is B4A 13 now causing a new issue?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
11 to 13 is a big jump, mainly due to the sdk.

just to double check: in addition to updating to 13,
you also did the whole new sdk update? plus switching to
java 19.0.2?

i looked at reasons why you would see the failure to inflate
error. there are many, most relating to incompatability.
making sure you have the right sdk might get you past this.

erel added a lot of dependencies for 13, stuff that we used
to have to add manually and jetify. it's all internal now.
(or the latest versions available with the sdkmanager, if
necessary.)
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Yes, I installed the "Android SDK Command Line Tools" and "Required Resources" from https://www.b4x.com/b4a.html.

But I was able to get it working by instead using the B4A v11 of those two files. I then used the SDK Manager and installed Android SDK Platform 34 and set the path to it and the app compiles and runs without any errors.

Will using the version 11 of the Command Line Tools and Required Resources instead of the ones listed on https://www.b4x.com/b4a.html cause any problems?
 
Upvote 0
Top