Android Tutorial [java] Video tutorial - Creating a simple library

barx

Well-Known Member
Licensed User
Nice and easy to follow. 1 question.

To use the coded method you have to.
B4X:
dim fl as FirstLib

then use
B4X:
x = fl.Multiply(10)

Is it possible to make it so that you simply use

B4X:
x = Multiply(10)

Thanks
 

corwin42

Expert
Licensed User
Is it possible to make it so that you simply use

B4X:
x = Multiply(10)

You can create your own sub for this but I see not a big advantage in doing so.

B4X:
Sub Multiply(value as Int) as Int
   Dim fl as FirstLib
   return fl.Multiply(value)
End Sub
 

barx

Well-Known Member
Licensed User
Hi corwin42.

Yeah I know I could. It's not for this exact lib. just using it as an example. I'm creating 'another' simple, but more usable, lib as part of my learning curve and wondered if the above could be done.

Trying to learn to do libs you see.

Cheers

edit: I wish to do it so the function can be used much like a 'built in' function. x = function(y) as opposed to x = ab.function(y)
 

Bardill

Member
Licensed User
NoClassDefFoundError

Hi Erel
I have testing the sample
i can compile it but i have an exeption by the line

Dim fl as FirstLib

java.lang.NoClassDefFoundError:

can you help me?
 

Bardill

Member
Licensed User
NoClassDefFoundError

hi erel here is the jar file and the message

mDVFSLock.acquire()
id=792(79) createSurface 0x3776c (1x1),2 flag=400
Shutting down VM
onPause. Launcher: 41502bf0
GC_CONCURRENT freed 99K, 81% free 496K/2560K, paused 0ms+0ms
NOTE: attach of thread 'Binder Thread #3' failed
Start proc app.processName for activity hostingNameStr: pid=13057 uid=10035 gids={3003, 3002, 1015, 1023}
Skipped drawing due to suspendDrawingUntilResume()
Turning on JNI app bug workarounds for target SDK version 4...
GC_EXPLICIT freed 894K, 32% free 25658K/37255K, paused 3ms+10ms
Could not find class 'myfirstlib.notenstein.NotensteinLib', referenced from method notenstein.ch.main._process_globals
VFY: unable to resolve new-instance 419 (Lmyfirstlib/notenstein/NotensteinLib;) in Lnotenstein/ch/main;
VFY: replacing opcode 0x22 at 0x000e
DexOpt: unable to opt direct call 0x07bd at 0x10 in Lnotenstein/ch/main;._process_globals
getActualApplicationStateEnabled() : true
getActualApplicationStateEnabled() : true
id=793(1) createSurface 0x4f93c (1x1),2 flag=400
id=794(2) createSurface 0x4e644 (1x1),1 flag=0
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40c4a1f8)
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: myfirstlib.notenstein.NotensteinLib
at notenstein.ch.main._process_globals(main.java:289)
at notenstein.ch.main.initializeProcessGlobals(main.java:264)
at notenstein.ch.main.afterFirstLayout(main.java:80)
at notenstein.ch.main.access$100(main.java:16)
at notenstein.ch.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Force finishing activity r.intent.getComponent().flattenToShortString()
GC_CONCURRENT freed 115K, 3% free 9156K/9351K, paused 1ms+2ms
getActualApplicationStateEnabled() : true
!@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error
CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=true left=false top=false
Check if stand-alone
begin
id=790 Removed idx=1 Map Size=8
id=790 Removed idx=-2 Map Size=8
getActualApplicationStateEnabled() : true
id=791 Removed idx=0 Map Size=7
 

Attachments

  • BaFiles.zip
    1.9 KB · Views: 303

ukimiku

Active Member
Licensed User
Thanks for the clear video.
Could you please post a link to the doclet tool here as well? Thank you.

Regards,
 

birnesoft

Active Member
Licensed User
Good stuff

Hello Erel
B4A is the best program I know.:sign0100:
And now this VideoTutorial opens the horizont to the java flexibility for me.:sign0098:
In 20 minutes my first lib was working.

thanks 1000 times!:sign0060:

Björn

PS.:
Public Libs comming soon!!
 
Last edited:

TestEngineering

New Member
Licensed User
Application stopped uexpectedly when using the library created

Hi Erel,

I followed the Video tutorial for the creation of library, I generated the jar and xml file, but when i am using it in the Basic4android I encountered error forcing the application to close . I also have this logs.
Kindly help...
Thanks.

:(:(:(

main_process_globals (java line: 249)


java.lang.NoClassDefFoundError: anywheresoftware.b4a.sample.FirstLib


at te.lio.as.main._process_globals(main.java:249)
at te.lio.as.main.initializeProcessGlobals(main.java: 229)
at te.lio.as.main.afterFirstLayout(main.java:80)
at te.lio.as.main.access$100(main.java:16)
at te.lio.as.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:587 )
at android.os.Handler.dispatchMessage(Handler.java:92 )
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.jav a:4263)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:597)
at dalvik.system.NativeStart.main(Native Method)
 

djpero

Member
Licensed User
I was followed complete video tutorial, and I have no errors but cannot locate the Jar file. The xml file is created properly?
 

Similar Threads

Top