Creating Patch Files to Apply to the Cross-Compiled Code
A patch file is a standard difference (diff) file that you can create. Use patch files when you need to make changes to the code that the Mobile Designer cross compiler creates. For example:
You might need to correct issues that prevent the code from compiling.
You might need to correct issues when the code cross compiles correctly, but the resulting code does not execute as expected.
For example, in your source Java code, you use multiple post increments, such as i++ in one line of code:
int rgb = (data[i++] << 16) + (data[i++] << 8) + (data[i++]);
This line of code can cross-compile to C++ fine, but cannot be guaranteed to execute as Java does. In some C++ compilers this type of code might result in “undefined behavior.” In this case, even though the code will convert to C++ and then compile successfully, you might find the run-time execution is incorrect. For these types of situations, it is usually a best practice to write a more compliant variant in your Java code. Continuing this example, you might change the original Java code to something like the following:
int rgb = (data[i] << 16) + (data[i + 1] << 8) + (data[i + 2]);
You create the patch file one time, and
Mobile Designer automatically applies the fix to all future builds, even if you continue to make changes to your application’s original Java code. For instructions about how to create a patch and where to store the patch file, see
Creating a Patch.
When Mobile Designer builds your project, it adds a Builds folder to your project folder. Within the Builds folder, there are folders for each device for which your application was built.
project/Builds/x.y.z/device
In the folder location above:
project is the name of your project.
x.y,z is the version number you specified for the build.
device is the name of a device for which
Mobile Designer built your application.
The device folder contains a _temp_/_language_ folder that contains the version of the cross-compiled code without a patch applied. If a patch file exists, Mobile Designer patches the code and stores the resulting patched version of your project in the _temp_/_language_edit_ folder. For example, for Android, Mobile Designer generates a _java_edit_ folder along side the _java_ folder, or for Windows Phone Mobile Designer generates a _csharp_edit_ folder along side the _csharp_ folder.