Android Question error asigning map returning sub to a map object

leitor79

Active Member
Licensed User
Longtime User
Hi,

I have this line and I'm getting an error:

Code: Copy
Dim lconv As Map
lconv=Config.GetMap

"Config.GetMap" is declared like this:

Code: Copy
Public Sub GetMap() As Map

There, at GetMap sub, I have an object declared as Dim r As Map, and the last line is "Result r"

I also have Try-Catch blocks on every sub. I've put a breakpoint at the catch sentence of the GetMap sub, but is not triggered. The first line of GetMap sub also is not triggered. However, the catch sentence of the caller sub (the one with the lconv=Config.GetMap line, where I'm getting the error) is triggered and some stuff is logged:

lastexception.message: java.lang.Exception: java.lang.NullPointerException

Error occurred on line: 123 (clsMensaje)
java.lang.NullPointerException
at anywheresoftware.b4a.debug.RDebugUtils.setLastException(RDebugUtils.java:17)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:712)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:244)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
at anywheresoftware.b4a.BA$3.run(BA.java:334)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)

So, it looks is something wrong with the assignment?

Thank you very much!
 
Hi Erel,

The project won't work; you'd need a facebook account, contacts who uses the app, an access to an mqtt server... very complicated to get it work. I've made a small project with the same layout (a class, a module, the assignment made from the class's initialize sub), but it works OK, no exception is raised. The GetMap sub, on the "big" project, is also called from other process and no error is raised either.

Thank you very much for your answer! I'll keep debugging.
 
Upvote 0
Problem solved. It has nothing to do with the map. It has to do with this

The error line (lconv=Config.GetMap) is on a sub called "initialize2". I thought naming a sub "initialize2" would overload the initialize sub, but now I know it wont. For some reason, class.initialize2 was called and executed without error even when I didnt't call initialize first. Several lines are executed (the error is raised at line 123?) when, for some reason, the exception raises at the GetMap call.

I've made some modifications, put an .initialize before the initialize2 and now it works fine.

Thank you very much!
 
Upvote 0
Back
Top