B4J Question Integrated Packager not working?

Guenter Becker

Active Member
Licensed User
Longtime User
Hi,
I developed a small B4J Project for my license management. (Download).
If I start the compilation to get a standalone package all went well with no error messages.
After starting the installed exe in the C:\Programmfiles directory a window is flashing up shortly and thats all.
I substitue the App Name Example in the .iss and start the Inno compiler. No errors.
Checked all packager commands against isnfos in the forum and found no errors.

B4J 19.0.2
Inno Setup compiler 6.7.0
Windows 11

If I start the project in the project suite there are no error it's works well.

Therefore I need some help where is the problem because this project is my start up to create standalone B4J Apps in future.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Run the run_debug.bat file that will be in the application's folder within Program Files and see what errors are shown.
That is indeed the first step.

If the package works when running from the "build" folder and fails when running from Program Files then it is probably related to mistakenly using File.DirApp for write access.

Use XUI.DefaultFolder instead. And make sure to call XUI.SetDataFolder first.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Longtime User
That is indeed the first step.

If the package works when running from the "build" folder and fails when running from Program Files then it is probably related to mistakenly using File.DirApp for write access.

Use XUI.DefaultFolder instead. And make sure to call XUI.SetDataFolder first.

I checke the code and implementet XUI.Default folder beeing set to DiApp Foldeer.
Recompiled it to standalone package. No Errors.
Startet EXE File in temp folder same error shortly flashing window.
Batchfile for InnoSetup starts automatically and runs with no error installs App in ProgrammFiles.
Starting App from Programmfiles causes the same error.
Checked run_debug.bat.
Notice! File Licence.DB exists in Objects and FIles.
1781608485232.png
 

Attachments

  • cmd_9r09lSVwEV.png
    cmd_9r09lSVwEV.png
    50.8 KB · Views: 11
Upvote 0

Guenter Becker

Active Member
Licensed User
Longtime User
I checke the code and implementet XUI.Default folder beeing set to DiApp Foldeer.
Recompiled it to standalone package. No Errors.
Startet EXE File in temp folder same error shortly flashing window.
Batchfile for InnoSetup starts automatically and runs with no error installs App in ProgrammFiles.
Starting App from Programmfiles causes the same error.
Checked run_debug.bat.
Notice! File Licence.DB exists in Objects and FIles.
View attachment 171861
Reading the run_debug file the named error is that the file Licence.db is not copied to then temp/bin folder. Don't no why! I copied the file manually to that folder an run the Innoscript again.
Result:
- starting the app from the temp folder App is loaded and working.
- starting the App from the Programmfiles folder App is loaded and working.

Conclusion:
The error is that the existing file licence.db (existing in Objects and Dir Assets) is not copied to the temp/bin folder by the packager!!
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Longtime User
Post the line with SQL.InitializeSQLite
B4X:
    xui.SetDataFolder(File.DirApp)
    sql.InitializeSQLite(xui.DefaultFolder,"Licence.db",False)
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
I'm sure @Erel will answer better than me, but as I understand your app wants to write to licence.db (and not just read from it), shouldn't it be put in a writeable folder and not just File.DirApp.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Longtime User
I'm sure @Erel will answer better than me, but as I understand your app wants to write to licence.db (and not just read from it), shouldn't it be put in a writeable folder and not just File.DirApp.
May be Ok but at present we are not at this point. Yet the packager does not copy the file to the temp/bin folder. Therefore it's not copied later in the Programmfiles folder. And therfore the programm starts wants to initialize the sql and that fails to the result that the app crashes.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
xui.SetDataFolder(File.DirApp)
This is a mistake.

The whole idea is that the "current folder" (Program Files in this case) is non-writable. The correct place is a bit hidden in Windows and is referenced in B4J with XUI.DefaultFolder (or File.DirData). You need to set it like this:
B4X:
XUI.SetDataFolder("Your app name here")
It will be something like:

C:\Users\<user name>\AppData\Roaming\<app name>
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
Yet the packager does not copy the file to the temp/bin folder. Therefore it's not copied later in the Programmfiles folder.

While again I'm sure @Erel can answer better than me, as I understand it, files in the files folder are not simply copied into temp/bin, but are embedded into the resultant .exe file.

For instance when using jSerial it is necessary to copy jssc.dll there and so as per Tip 5 in https://www.b4x.com/android/forum/t...-way-to-distribute-standalone-ui-apps.117880/ this is used to do that:

B4X:
#CustomBuildAction: After Packager, %WINDIR%\System32\robocopy.exe, ..\ temp\build\bin\ jssc.dll

And so that approach would put your Licence.db in the Windows application folder, but I believe that is not good practice for a file such as yours and so @Erel's recommendation should be followed.

It's also worth looking at the Files options available in Inno Setup for copying files when creating the installer. For instance here is an example I use:

B4X:
#define MyAppName "BDSSynergyPlayerBoard"
#define MyAppPublisher "BDS Consulting"

[Files]
Source: Objects\temp\firstrun; DestDir: {commonappdata}\{#MyAppPublisher}\{#MyAppName}; Flags: ignoreversion; Permissions: users-modify

which copies a writeable configuration file to the C:\ProgramData folder rather than in a specific user's C:\Users\<user name>\AppData\Roaming\
 
Upvote 0
Top