Android Question a simple program, crashes before start

67biscuits

Member
Posted here is the entire code that crashes on start up. Ver 13.70 64bit with a Sonim XP800 Android 14

B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

#Macro: Title, Export B4XPages, ide://run?File=%B4X%\Zipper.jar&Args=%PROJECT_NAME%.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub
 

LucaMs

Expert
Licensed User
Longtime User
You should always include the error message.

I assume that is a project that was originally a B4XPages, but you only have the B4A folder and missing the SharedFiles folder, causing this line:
B4X:
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
which attempts to run Robocopy.exe to copy resource files from the "Shared Files" folder to the B4A project's "Files" folder, causing the project to crash.

You just need to comment out that line.
 
Last edited:
Upvote 0

teddybear

Well-Known Member
Licensed User
which attempts to run Robocopy.exe to copy resource files from the "Shared Files" folder to the B4A project's "Files" folder, causing the project to crash.

You just need to comment out that line.
This will only cause a compile-time error, not a runtime crash.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

67biscuits

Member
You should always include the error message.

I assume that is a project that was originally a B4XPages, but you only have the B4A folder and missing the SharedFiles folder, causing this line:
B4X:
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
which attempts to run Robocopy.exe to copy resource files from the "Shared Files" folder to the B4A project's "Files" folder, causing the project to crash.

You just need to comment out that line.
I will do that. Why would it be there in the first place? I clicked on File > New > B4XPages and that's what I was given. I changed the name to M Project > Build Config > Package and in the Application label in the Main module. This is more a curiosity than anything.
How would I prevent this happening again going forward?

Cheers
 
Upvote 0

67biscuits

Member
Where is the full crash-log????

UPLOAD a zip with the code, manifest, Layouts. NO ONE can help with your codesnippet.

See https://www.b4x.com/android/forum/threads/for-new-er-members-how-to-post-a-question-issue.96964/
I don't think it needs to be zipped:

Full crash Log:

(Intentionally blank)

Code from Main Module:

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A m
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #EdgeToEdgeOldDevices: True
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

'#BridgeLogger: True

Sub Process_Globals
    Public ActionBarHomeClicked As Boolean
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

'Template version: B4A-1.01
#Region Delegates

Sub Activity_ActionBarHomeClick
    ActionBarHomeClicked = True
    B4XPages.Delegate.Activity_ActionBarHomeClick
    ActionBarHomeClicked = False
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Sub Activity_Resume
    B4XPages.Delegate.Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    B4XPages.Delegate.Activity_Pause
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub

Sub Create_Menu (Menu As Object)
    B4XPages.Delegate.Create_Menu(Menu)
End Sub

#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
     processBA.raiseEvent(null, "create_menu", menu);
     return true;
    
}
#End If
#End Region

'Program code should go into B4XMainPage and other pages.

Code from the Bx$MainPage:
B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

#Macro: Title, Export B4XPages, ide://run?File=%B4X%\Zipper.jar&Args=%PROJECT_NAME%.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

and finally the Manifest Editor:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="36"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.

Layout:
'All variants script
AutoScaleAll

The layout has one button called Button1, any code involved with that is posted above in the B4XMainPage section.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
The Logs are relevant because they show alerts, if the issue is before compilation, during compilation, after compilation, of anything else!
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
I will do that. Why would it be there in the first place? I clicked on File > New > B4XPages and that's what I was given. I changed the name to M Project > Build Config > Package and in the Application label in the Main module. This is more a curiosity than anything.
How would I prevent this happening again going forward?

Cheers

ok, do it again please
File > New > B4XPages
don't change anything and F5
Does it work ?
If yes then try to change
Project > Build Config > Package
and run it again
Then change
Application label in the Main module
and try run again
and so on, step by step until you find the problem
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Again, without knowing what exactly fails (and for that we need the logs), we are only guessing!
 
Upvote 0

67biscuits

Member
ok, do it again please
File > New > B4XPages
don't change anything and F5
Does it work ?
If yes then try to change
Project > Build Config > Package
and run it again
Then change
Application label in the Main module
and try run again
and so on, step by step until you find the problem
Ok, it has stopped connecting again. I have to go back and try to remember what i did last it stopped connecting, get that working again, and then i can see about the code
 
Upvote 0

67biscuits

Member
ok, do it again please
File > New > B4XPages
don't change anything and F5
Does it work ?
If yes then try to change
Project > Build Config > Package
and run it again
Then change
Application label in the Main module
and try run again
and so on, step by step until you find the problem
I reconnected the bridge, my firewall was set too tightly.
Apparently my firewall had a seizure and blocked most of the phone off from the world. I have some examining to do and reset the firewall settings.
So sorry to have started all this about nothing.
 
Last edited:
Upvote 0
Top