Bug? Sender: Object should first be initialized (ImageView).

guenneguez_t

Member
Licensed User
Longtime User
Hi,

In a fonction I use : Sender
In Debug mode every thing is fine.
When I compile in Release mode, I have the following error :
java.lang.RuntimeException: Object should first be initialized (ImageView).
My sub function is :
B4X:
Sub ImageViewSerie_Click
    Dim Trigger As ImageView
    Dim Serie As String
    Debug("Sub ImageViewSerie_Click")
    Debug("Sender.tag : " & Sender)
    Trigger = Sender
    Serie = Trigger.Tag
In the log, I have :
22:44:24:976 Main Sub ImageViewSerie_Click
22:44:24:980 Main Sender.tag : null
main_imageviewserie_click (java line: 4692)
java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.ViewWrapper.getTag(ViewWrapper.java:261)
at com.guenneguez.VoileChrono.main._imageviewserie_click(main.java:4692)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7185)
at android.view.View.performClickInternal(View.java:7162)
at android.view.View.access$3500(View.java:819)
at android.view.View$PerformClick.run(View.java:27678)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7590)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
java.lang.RuntimeException: Object should first be initialized (ImageView).

I have got the problem with all usage of "Sender".
I try with Button, and have the same problem.

It seem like Sender objet wasn't defined...

Thanks
Thomas
 

William Lancee

Well-Known Member
Licensed User
Longtime User
The order of your statements is wonky. I assume ImageViewSerie is an ImageView with the Tag property set

B4X:
Sub ImageViewSerie_Click
    Dim Trigger As ImageView = Sender
    Dim Serie As String = Trigger.Tag
    Debug("Sub ImageViewSerie_Click")
    Debug("Trigger.tag : " & Serie)
 

guenneguez_t

Member
Licensed User
Longtime User
Thanks for reply.
I test as explain by William Lancee and it work fine.
I juste replace :
B4X:
Dim Trigger As ImageView
Trigger = Sender
By
B4X:
Dim Trigger As ImageView = Sender

Before every think work good but an update (I don't know where) break apps

Best regards
Thomas
 

William Lancee

Well-Known Member
Licensed User
Longtime User
Before every think work good but an update (I don't know where) break apps

Yes, that changes everything. My apologies for saying it was the order. The two fragments of code in post #4 are the same.
Assuming it was an App update, you need to find out what the update changed to break things.
Create a minimal App that works and add the changes that were made - a little at a time.
 
Top