It is possible to embed files directly in the compiled libraries by following these steps:
1. Add the attached class module, JarFileLoader, to your code (Project - Add Existing Module).
2. JarFileLoader can either load files from the Files folder or from the compiled jar.
While you develop the library you should initialize it and set it to load files from the assets folder:
3. Before you compile the library you should make sure to change jfl.Initialize(True) to jfl.Initialize(False).
4. The files from the Files folder will not be included automatically in the compiled jar. You need to compile the library and then open the jar file with a program such as 7zip and copy the files to the jar.
The files names are case sensitive. It is recommended to use all lower case names as the IDE will automatically lower case the names when you add the files to the Files tab.
1. Add the attached class module, JarFileLoader, to your code (Project - Add Existing Module).
2. JarFileLoader can either load files from the Files folder or from the compiled jar.
While you develop the library you should initialize it and set it to load files from the assets folder:
B4X:
Sub Process_Globals
Private jfl As JarFileLoader
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
jfl.Initialize(True) '<--- True = from assets folder, False = from jar file
End If
Activity.SetBackgroundImage(jfl.LoadBitmapFromJar("smiley.gif"))
End Sub
3. Before you compile the library you should make sure to change jfl.Initialize(True) to jfl.Initialize(False).
4. The files from the Files folder will not be included automatically in the compiled jar. You need to compile the library and then open the jar file with a program such as 7zip and copy the files to the jar.
The files names are case sensitive. It is recommended to use all lower case names as the IDE will automatically lower case the names when you add the files to the Files tab.