Android Question On a smartphone, the application closes immediately after launching

zbyniok

New Member
Text by Google translator


Hello,
I'm having a problem with apps closing on my smartphone immediately after launching.
This applies to apps that access the AP and initiate UDP.

B4A version 13.40 (64-bit) Windows 10
C:\Program Files\Java\jdk-19\bin\javac.exe
C:\android\platforms\android-36\android.jar

Android 16

Everything compiles and loads correctly.

Despite removing the line from the code as below and updating it, the error persists.

Please help me.

Regards.


Sub udp_init(sport As String)
udp.Initialize("",sport,1025)
End Sub

Sub header_init(sport As String)
tytul_strony="B4A Pages 2 (" & MyLan.GetMyIP & ":" & sport & ")"

End Sub
 

Peter Simpson

Expert
Licensed User
Longtime User
I'm having a problem with apps closing on my smartphone immediately after launching.
This applies to apps that access the AP and initiate UDP.

You need to post what the logs say, without the logs, it's not easy to say...
 
Upvote 0

zbyniok

New Member
You need to post what the logs say, without the logs, it's not easy to say...

short log is

Error occurred on line: 60 (B4XMainPage)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at b4a.my.b4xpages2.b4xmainpage.innerInitialize(b4xmainpage.java:21)
at b4a.my.b4xpages2.b4xmainpage._initialize(b4xmainpage.java:229)
at b4a.my.b4xpages2.b4xpagesmanager._initialize(b4xpagesmanager.java:152)
at b4a.my.b4xpages2.main._activity_create(main.java:417)
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:157)
at b4a.my.b4xpages2.main.afterFirstLayout(main.java:105)
at b4a.my.b4xpages2.main.access$000(main.java:17)
at b4a.my.b4xpages2.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:995)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loopOnce(Looper.java:273)
at android.os.Looper.loop(Looper.java:363)
at android.app.ActivityThread.main(ActivityThread.java:10060)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: java.lang.RuntimeException: Object should first be initialized (B4XView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at b4a.my.b4xpages2.b4xmainpage._class_globals(b4xmainpage.java:222)
... 22 more
** Activity (main) Resume **

line 60 is in B4XMainPage

Sub Class_Globals
Private ivS1 As B4XView
Private ivS3 As B4XView
Private ivS5 As B4XView
Private ivS2 As B4XView
Private ivS4 As B4XView
Private ivS6 As B4XView

Dim ivSx(ile_slave+2) As ImageView=Array As ImageView(iv_1,iv_1,iv_2,iv_3,iv_4,iv_5,iv_6)

End Sub

the compiler does not report errors
but I use it in another module

I know, I must change from Private to Public, isn't it?
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I also point that your tread title is misleading, as it leads to suppose it works on other devices other than smartphones.
 
Upvote 0

zbyniok

New Member
I also point that your tread title is misleading, as it leads to suppose it works on other devices other than smartphones.

OK
out of five apps on my smartphone, 4 close immediately and one starts
and not always the same
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
F.Y.I. Noticed 2 other potential problems in...
B4X:
Dim ivSx(ile_slave+2) As ImageView=Array As ImageView(iv_1,iv_1,iv_2,iv_3,iv_4,iv_5,iv_6)

1. You don't usually specify the size of the array when you assign an Array as XXX(a, b, c) to it. It will automatically give it the size of the new Array.
2. You are putting iv_1 in the Array twice. That is ok if you intended that - but be warned if it not intended.

They won't cause any error messages but:
I 'guess' after loading the layout, you meant to do...
B4X:
Dim ivSx() As ImageView=Array As ImageView(iv_1,iv_2,iv_3,iv_4,iv_5,iv_6)

I'm just responding on a slow Sunday :)
 
Upvote 0
Top