Android Question java.lang.ClassNotFoundException: Invalid name: b4a.example.class b4a.example.main

hatzisn

Expert
Licensed User
Longtime User
Good morning everyone,

I have created a class and in initialize i set a private in the class variable mCallBack as object. This code breaks in the highlighed line:

B4X:
Sub Class_Globals
    Private mEvent As String
    Private mCallBack As Object
End Sub

Sub Initialize(CallBackObject As Object, EventName As String)
    mCallBack = CallBackObject
    mEvent = EventName
End Sub

Sub UpdateTheCallingObject
     Log(mCallBack)
     If SubExists(mCallBack, mEvent & "_ConcludedProcedure") Then
          CallSub(mCallBack, mEvent & "_ConcludedProcedure")
     End If
End Sub

The same code in B4J works. It is as somehow the code cannot locate the calling object as it is not apparent though it is set.

I instantiate the class with the followng code in the Main Activity (Activity_Create):

B4X:
ft.Initialize(Me, "ft")


Here is the error (it has no logic since as you can see the Log(mCallBack) shows the class) :

class b4a.example.main
Error occurred on line: 178 (FT)
java.lang.ClassNotFoundException: Invalid name: b4a.example.class b4a.example.main
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.keywords.Common.getComponentBA(Common.java:1218)
at anywheresoftware.b4a.keywords.Common.SubExists(Common.java:1007)
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:348)
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 anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
at b4a.example.comms._astream_newdata(comms.java:319)
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 anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
 
Last edited:

hatzisn

Expert
Licensed User
Longtime User
Can somebody explain to me the output of this trial project? I mean the output you get in the first time you click the button...
 

Attachments

  • BugWithClasses.zip
    10 KB · Views: 224
Upvote 0
Top