Android Question Error loading file in the designer [appears solved...]

Didier9

Well-Known Member
Licensed User
Longtime User
Just upgraded B4A in my backup computer. I had not used that computer in probably a year. I first had an issue which I traced to a forum post recommending to upgrade the tools so I did that.
Now the app crashes when I open a particular activity, on the Activity.LoadLayout() statement. When I try to open the layout in the designer, I get the error message attached.
I also attached the layout file.
The app compiles, loads and runs fine when I use the other laptop.
The two machines are otherwise almost identical.
Any help appreciated!
 

Attachments

  • b4a.png
    b4a.png
    7.8 KB · Views: 121
  • selectbluetooth.bal
    7.6 KB · Views: 100

drgottjr

Expert
Licensed User
Longtime User
file appears to contain nothing but nulls...
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I am not sure what happened, I may have copied the file before it was fully restored from the backup. That's not the cause of the problem, even though it would have definitely been a problem on its own... This is the "proper" file. It works in the "main" laptop but not in the "backup" laptop.
It crashes the app when I try to open this activity with this error and crashes the designer when I try to open the layout file with the error message in the original post.
Error occurred on line: 29 (SelectBluetooth)
java.lang.RuntimeException: java.lang.NullPointerException: Attempt to read from field 'float anywheresoftware.b4a.keywords.LayoutValues.Scale' on a null object reference
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.edsfl.fusex.selectbluetooth._activity_create(selectbluetooth.java:386)
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.edsfl.fusex.selectbluetooth.afterFirstLayout(selectbluetooth.java:105)
at b4a.edsfl.fusex.selectbluetooth.access$000(selectbluetooth.java:17)
at b4a.edsfl.fusex.selectbluetooth$WaitForLayout.run(selectbluetooth.java:83)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to read from field 'float anywheresoftware.b4a.keywords.LayoutValues.Scale' on a null object reference
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:127)
... 18 more
** Activity (selectbluetooth) Resume **
 

Attachments

  • selectbluetooth.bal
    7.6 KB · Views: 94
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
the file is still 7.6kb of nulls. the error message seems to imply there is a problem with the layout. if you're looking for the mentioned null object reference, you've got 7.6kb of them in that file. if the file you're posting is a valid layout file, i do apologize, but i've never had a problem downloading a file from here.
 

Attachments

  • dump.png
    dump.png
    21.9 KB · Views: 102
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
This is mind blowing...
That's the second time. I looked at the file before attaching it to this post and it was not blank. Now it's blank.
The two laptops share files via Sync.
I do not normally run the software from the shared drive (it causes issues with a bunch of apps) so each laptop has a local folder where I run the software from, then for backup, I copy the working folder to the Sync folder. When I want to run the same software on the other laptop, I copy from the Sync folder back to the other laptop's local drive.
This has worked for many many years. I do this with my C source code and B4J, and I was doing it with Visual Basic before that. I used Dropbox before Sync.
Well, I am working (and sending this message) from the "main" laptop now and this is the file...

This all started because I got a newer new laptop last Friday (so there are 3 at the moment, the main, the backup and the new), so I started the process of copying and installing everything on that new laptop and I thought I would check the old backup machine to make sure the process worked as I expected. That's when the problem started.
The good news is that the new laptop seems to be behaving normally, no issue with that file or with running the app once loaded on the phone (but a strange issue that I cannot load the app via USB on the new laptop, only with B4A Bridge. It's the same phone, same version of B4A and same Windows 10... But that's another issue.)

Anyhow, there seems to be a weird problem with Sync on the backup machine, so I am going to take it offline until I figure it out.

Sorry for the distraction. I'll update when I have something.
 

Attachments

  • selectbluetooth.bal
    7.6 KB · Views: 95
Last edited:
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
So I downloaded the file from the forum back on the backup machine, renamed the previous (blank) one with the name selectbluetooth2.bal and opened the old and new in WinMerge and got this:
1637063488485.png


I have to go to work now but I will try again tonight. I have no idea why that particular file seems to change after it's copied from the Sync folder...
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I think I found the problem.

When copying files to the Sync folder, it would initially create the directory structure with empty files (0 length), then populate the files according to some algorithm. So before copying files back to another place, I just had to wait until Explorer reported a size >0. Convenient.

Apparently they must have changed something because that's not the way it works now. It seems to create an empty file of the proper size but containing only nulls, then later on the file is actually filled with data.

So the problem was that I was copying the file from the Sync folder to the local folder before it was actually transferred. And since it was the right size but not working, I would copy it again from the source computer, so it never had a chance to actually update.

It may have been compounded by a slow network. My internet connection is usually good enough (I have a business account with a fixed IP and 250Mb/s, or at least that's what I pay for...) that when copying a relatively small amount of data like this app from one computer to another, by the time I get off my chair and to the other machine, everything was transferred. That was obviously not the case yesterday or this morning.

After a day at work, all is working now.

Sorry for the bandwidth...
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
pre-populating the file with nuls was a nice touch. remember "sneakernet"? worked then, still works now.
 
Upvote 0
Top