Android Question application collapsed

yaniv hanya

Active Member
Licensed User
Hello
I ziped a project and sent it to my boss and when he tried to run it on the second screen loading the application collapsed and he got the following mistake
Error occurred on line: 23 (HomeScreen)

java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).

at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)

at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)

at b4a.example.homescreen._activity_create(homescreen.java:361)

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 b4a.example.homescreen.afterFirstLayout(homescreen.java:104)

at b4a.example.homescreen.access$000(homescreen.java:17)

at b4a.example.homescreen$WaitForLayout.run(homescreen.java:82)

at android.os.Handler.handleCallback(Handler.java:836)

at android.os.Handler.dispatchMessage(Handler.java:103)

at android.os.Looper.loop(Looper.java:203)

at android.app.ActivityThread.main(ActivityThread.java:6251)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

Caused by: java.lang.RuntimeException: Object should first be initialized (ImageView).

at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)

at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:73)

at anywheresoftware.b4a.objects.ImageViewWrapper.innerInitialize(ImageViewWrapper.java:36)

at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:435)

at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)

at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)

... 18 more

** Activity (homescreen) Resume **

Copying updated assets files (50)

*** Service (starter) Create ***

** Service (starter) Start **

** Activity (main) Create, isFirst = true **

** Activity (main) Resume **

Ready


When I opened the file I sent to him he ran nicely (just change the text color on one of the screens).

Something similar happened to me early on in the project after several times that he ran well he began to crash each time with the following mistake
** Activity (homescreen) Create, isFirst = true **
Error occurred on line: 23 (HomeScreen)
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.homescreen._activity_create(homescreen.java:363)
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 b4a.example.homescreen.afterFirstLayout(homescreen.java:104)
at b4a.example.homescreen.access$000(homescreen.java:17)
at b4a.example.homescreen$WaitForLayout.run(homescreen.java:82)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:408)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
... 18 more
** Activity (homescreen) Resume **

And I could not get over the problem just by opening a new project and copying item item to it separately. Then it ran nicely and on this new project I work today.
Do you have an idea how to solve both problems?
Thanks​
 

ronell

Well-Known Member
Licensed User
please post the relevant code, it will help us to find and resolve the problem
 

yaniv hanya

Active Member
Licensed User
Hello,
I still got the problem-
when the app try to load the activity (Activity.LoadLayout("homescreen"))

the app crush. I tried to remove all declaration, and made the WYSIWYG editor to add the globals, to prevent mistakes, but I still get the same problem.

the weird thing is that it is work in my developer machine, but when I move it to my personal machine, I get the error.

this is the activity code:
B4X:
#Region  Activity Attributes
    #FullScreen:  True
    #IncludeTitle: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim timer1 As Timer
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private dateLb As Label
    Private timeLb As Label
    Private Panel1 As Panel
    Private infoBtn As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("homescreen")
    DateTime.DateFormat = "EEE, MMM d, yyyy"
    Dim d As Long=DateTime.Now
    Dim ds As String=$"$DateTime{d}"$
    Dim sd1() As String=Regex.Split(" ", ds)
    dateLb.Text=sd1(0) & " " & sd1(1) & " " & sd1(2) & " " & sd1(3) & " " & sd1(4)  
    infoBtn.BringToFront
    timer1.Initialize("timer1",1000)
    timer1.Enabled=True
End Sub

Sub timer1_Tick
    DateTime.DateFormat = "EEE, MMM d, yyyy"
    Dim d As Long=DateTime.Now
    Dim ds As String=$"$DateTime{d}"$
    Dim sd2() As String=Regex.Split(" ", ds)
    timeLb.Text=sd2(5)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub infoBtn_Click
    If Panel1.Visible=False Then
        Panel1.Enabled=True
        Panel1.Visible=True
        infoBtn.BringToFront
    Else
        Panel1.Enabled=False
        Panel1.Visible=False
        infoBtn.BringToFront
    End If  
End Sub

Sub waterBtn_Click
    StartActivity(water)
End Sub

Sub Button1_Click
    StartActivity(Main)
End Sub
the layout file is attached
 

Attachments

Last edited:

AnandGupta

Well-Known Member
Licensed User
the weird thing is that it is work in my developer machine, but when I move it to my personal machine, I get the error.
Maybe the two machine have different B4A version or SDK version.
Maybe error is due to that.

Regards,

Anand
 

yaniv hanya

Active Member
Licensed User
and also as I mentioned
Something similar happened to me early on in the project after several times that he ran well he began to crash each time
And I could not get over the problem just by opening a new project and copying item item to it separately. Then it ran nicely and on this new project I work today.
The new project works fine in Debug mode.
But in release mode he falls and gives this mistake
homescreen_activity_create (java line: 355)
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.homescreen._activity_create(homescreen.java:355)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.example.homescreen.afterFirstLayout(homescreen.java:104)
at b4a.example.homescreen.access$000(homescreen.java:17)
at b4a.example.homescreen$WaitForLayout.run(homescreen.java:82)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:73)
at anywheresoftware.b4a.objects.ImageViewWrapper.innerInitialize(ImageViewWrapper.java:36)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:435)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
... 14 more
** Activity (main) Resume **
 

yaniv hanya

Active Member
Licensed User
well, donManfred, in a strange way your advice solved my problem. when I tried to zip the project, I got error message for not found file. it was a file that I deleted, but I couldn't zip it without that file. so I fixed it by rebuilding the layout.
but now I wonder- I didn't use that file anymore, nor could I see it in any of my files. and yet the IDE searched for it. I wonder if it is a bug (that even deleted files are listed in some way, and when not finding them the install collapse). or that I do something wrong and there is a specific way to delete files/ resources that wont last in some unseen list...
 
Top