Salesforce

Packaging Resource Files (Magic xpa 2.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

Packaging Resource Files (Magic xpa 2.x)

You can package resource files during the creation of the mobile packages (APK and IPA) and deploy them to the application cache folder on the client immediately after an installation or an upgrade. This means that these files are available to the Magic xpa programs without the need to retrieve them at runtime.

The main usage of this feature is to deploy the images and the local database when installing the package, instead of retrieving them from the server on the first execution.

To package these files, you need to place them in the assets folder, which is located at RIAModules\Android\Source and RIAModules\iOS\Source as detailed in the File Name Structure section below.

Note:

  • As for other (not packaged) files, when a file is used, the client checks for differences in the files’ modification date between the server copy and the cache copy. If the timestamp is different, the file will be retrieved from the server. This means that you must make sure that the files’ modification date on the deployment server is the same as the one on the machine that you used to build the client.

  • It is recommended to use the ServerFileToClient() function at startup on the folders of the cached files, for example: ServerFileToClient('images'). This action will verify that the client cache files are up to date and also will prevent the client from accessing the server when using the files later on in the application.

  • You cannot package platform specific resources (located in the Android/iOS subfolders).

  • You can also package the Magic xpa internal files, such as the color file, to provide an even faster first start.

File Name Structure

The assets folder should contain subfolders and files in the same structure as they are referred to in the Magic xpa programs. For example:

  1. For an image that is defined using the relative path of images\myimage.png, the assets folder should contain a subfolder named images, which should contain the myimage.png file. For example: assets\images\myimage.png.

  2. For an image that is defined using the full path of c:\images\myimage.png, the assets folder should contain a subfolder named c_ and this subfolder should contain a subfolder named images, which should contain the myimage.png file. Note that the colon (:) character after the drive letter should be replaced with an underscore when creating the first folder name. For example: assets\c_\images\myimage.png.

Note: Instead of creating nested subfolders, you can create one subfolder that is a concatenation of the subfolders separated by an underline, or even rename the image to have this path as part of the name. For example, the path of images\orders\contacts\myimage.png can be defined under the assets folder in various conventions, such as:

  1. Using the original file name and nested subfolders: assets\images\orders\contacts\myimage.png

  2. Using the original file name and one subfolder: assets\images_orders_contacts\myimage.png

  3. Using a modified file name and no nested subfolders: assets\images_orders_contacts_myimage.png

Verifying that the Files Were Properly Defined

As mentioned above, it is advised to use the ServerFileToClient() function in the startup program in order to verify that all the files are up to date and to improve performance for later usage in the files.

You can verify that the packaging is done correctly by adding Verify operations before and after the execution of the ServerFileToClient() function. The period of time between these two messages should be small since only the timestamps are checked and the files are downloaded again. You can also check the activity monitor and see that the ServerFileToClient() function performs only one request to the server.

Packaging Internal Files

There are cases in which it takes a long time for the application to load until the Main program is started.

This is usually caused when there are large environment files, such as a large color file, many menus, a large Main program or many components. All of these files need to be downloaded to the client and this may take some time (depending on the network bandwidth).

You can improve this first load time by packaging these files into your mobile packages (APK and IPA), which is similar to packaging resource files.

To find these files and package them, carry out the following steps:

  1. Delete the content of the servers’ RIA cache folder. By default, this is the RIACache folder under the installation folder. You can change the default in the Rich client cache path environment setting.

  2. Open the application using the runtime engine or run a client and connect to the application.

  3. Browse to the servers’ RIA cache folder. This folder now contains the cache files required for the application, such as myapp_ColorsTable_1.xml. You can take these files and put them in the assets folder (no need to rename the files). Now they will be part of the package and the client will not need to ask for them from the server.

Note that you do not need to update your application package every time these files are changed. If any of the files are changed, they will be automatically downloaded by the client.

Troubleshooting

If it still takes a lot of time to load the application for the first time, most likely the dates of the internal files in the servers’ RIA cache folder are different than the dates of the files in the assets folder. You can verify this by opening your mobile package (APK and IPA) using an archive extraction software, such as 7-zip.

Then, in the package, navigate to the assets folder and view the cachelist.txt file. This file is generated during the build process.

Each line in the file contains the resource file name and its timestamp. You should verify that the timestamp in the file is equal to the modification timestamp of the file in the servers’ RIA cache folder.

If the timestamps are different, re-copy the resource files from the servers’ RIA cache folder to the assets folder while making sure that the modification timestamp is not changed.

Since version:

2.4b

Reference
Attachment 
Attachment