Android Question Acvtivity.LoadLayout make trouble

BaGRoS

Active Member
Licensed User
Longtime User
I started with new project and
B4X:
Activity.LoadLayout("StartLayout")

makes error:
B4X:
Error occurred on line: 40 (Main)
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:208)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at bestsoft.game.followme.main.afterFirstLayout(main.java:102)
    at bestsoft.game.followme.main.access$000(main.java:17)
    at bestsoft.game.followme.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
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:71)
    at anywheresoftware.b4a.objects.ImageViewWrapper.innerInitialize(ImageViewWrapper.java:35)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:406)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:425)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:144)
    ... 20 more

I fight allmost two hours

unfiltered:
B4X:
AUDIO_OUTPUT_FLAG_FAST denied by client
START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=bestsoft.game.followme/.main (has extras)} from uid 10007 on display 0
addAppToken: AppWindowToken{310143df token=Token{196c227e ActivityRecord{18d8ec39 u0 bestsoft.game.followme/.main t51}}} to stack=1 task=51 at 0
failed to make and chown /acct/uid_10055: Read-only file system
createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
Adding window Window{3b0c9530 u0 Starting bestsoft.game.followme} at 2 of 7 (after Window{2a0a605a u0 com.android.launcher/com.android.launcher2.Launcher})
Start proc 3513:bestsoft.game.followme/u0a55 for activity bestsoft.game.followme/.main
Use EGL_SWAP_BEHAVIOR_PRESERVED: true
HostConnection::get() New Host Connection established 0xb429f9f0, tid 3513
Validating map...
Adding window Window{ccfa365 u0 bestsoft.game.followme/bestsoft.game.followme.main} at 2 of 8 (before Window{3b0c9530 u0 Starting bestsoft.game.followme})
HostConnection::get() New Host Connection established 0xaf039340, tid 3529
Initialized EGL, version 1.4
Enabling debug mode 0
eglSurfaceAttrib not implemented
Failed to set EGL_SWAP_BEHAVIOR on surface 0xaf035540, error=EGL_SUCCESS
Displayed bestsoft.game.followme/.main: +574ms
removeObsoleteFile: deleting file=50_task.xml
removeObsoleteFile: deleting file=50_task_thumbnail.png
Launch timeout has expired, giving up wake lock!
java.net.SocketTimeoutException
    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:99)
    at java.net.ServerSocket.implAccept(ServerSocket.java:216)
    at java.net.ServerSocket.accept(ServerSocket.java:140)
    at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:152)
    at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
    at java.lang.Thread.run(Thread.java:818)
Caused by: android.system.ErrnoException: accept failed: EAGAIN (Try again)
    at libcore.io.Posix.accept(Native Method)
    at libcore.io.BlockGuardOs.accept(BlockGuardOs.java:63)
    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:89)
    ... 5 more
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.stopProgram(Shell.java:175)
    at anywheresoftware.b4a.shell.Shell.connectionStatus(Shell.java:114)
    at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:135)
    at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference
    at bestsoft.game.followme.main.killProgram(main.java:336)
    ... 6 more
System.exit called, status: 0
VM exiting with result code 0, cleanup skipped.
failed to open /acct/uid_10055/pid_3513/cgroup.procs: No such file or directory
Process bestsoft.game.followme (pid 3513) has died
WIN DEATH: Window{ccfa365 u0 bestsoft.game.followme/bestsoft.game.followme.main}
Scheduling restart of crashed service bestsoft.game.followme/.starter in 20336ms
Force removing ActivityRecord{18d8ec39 u0 bestsoft.game.followme/.main t51}: app died, no saved state
eglSurfaceAttrib not implemented
Failed to set EGL_SWAP_BEHAVIOR on surface 0xa31f13c0, error=EGL_SUCCESS
Got RemoteException sending setActive(false) notification to pid 3513 uid 10055
Long monitor contention event with owner method=void com.android.server.AlarmManagerService$AlarmThread.run() from AlarmManagerService.java:1719 waiters=0 for 107ms
Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
 
Last edited:

JTmartins

Active Member
Licensed User
Longtime User
What's the line number of your Activity.LoadLayout("StartLayout") ?

Are you sure you're not using some imageview before loading the layout ?
 
Upvote 0

BaGRoS

Active Member
Licensed User
Longtime User
EDIT: I changed emulator on real device and error don't show, then debugger can show this error...


I found problem, in different sub I use:
B4X:
Sub Pauza(Czas As Int)

    Dim Czas_koniec As Long = DateTime.Time(DateTime.Now) + Czas 'this line make error!!


    Do While Czas_koniec > DateTime.Time(DateTime.Now)
        DoEvents
    Loop
 
End Sub

now I change properly

B4X:
Sub Pauza(Czas As Int)

    Dim Czas_koniec As Long = DateTime.Now + Czas


    Do While Czas_koniec > DateTime.Now
        DoEvents
    Loop
   
End Sub

and start working.
Of coz I make mistake but why compiler don't show this error?
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…