Skip to content

Step by step guide to create an Android application using PythonFMXBuilder

Priyatham edited this page Aug 19, 2022 · 6 revisions

Environment Setup

PythonFMXBuilderGUI_Debugger_Settings

Now the environment to build an Android application is set.

Project Setup

  • Click on the option Project > New project in the Project explorer section. Enter the name of the Android app that you want to build here. I've set it to Frames here as we're using Frame component of DelphiFMX package:

Builder_New_project

New_project_window

  • You can check the "Create Main File" option if you want the Builder to create a default main script file for you.
  • Add your Python script files and any other supporting project files that you use to create your application. One of the best practices is to take a modular approach in building your application. As per the modular approach, we can write all the implementations in separate Python files and call them from the main application Python file. Here, I added the frames.py and frames_main.py files from our GitHub samples using right click on mouse > Add file on the right-sided Project explorer window;

proj_files

  • Then copy and paste your main application code to the main.py code editor space. Here, I copy-pasted the frames_init.py from our GitHub samples;

image

  • Press on the Project button here:

image

  • It opens up a slider window from right to set up all the Project details.
  • You can see the name of your application is already set in the Application Name and Package Name fields. In my case, it is Frames which we've set at starting:

image

  • Provide the version information in the Version Info section. It depends upon your release schedule information.

image

  • We're shipping 3 Python versions - 3.8, 3.9, and 3.10 as part of the PythonFMXBuilder release. They're compiled on Android-NDK to support Python code on an Android device. You can choose one of those versions in Python Version section. We also support building apps on both 32 (arm) and 64 (aarch64) bit arm architectures.

image

  • You can set the app icon and splash screen image using the Application Icons section. Based on the device screen sizes and screen densities, you need to choose the image size of your splash screen and icon. In my case, my phone supports 470*320 size splash screen and 96*96 size icon.

image

Note: After setting all this Project options press on the Save button at the bottom.

Connect your device

First, you need to activate USB Debugging in your phone. To do that;

  • Open About Phone in your Settings, Open Version and press few times on the Build Number. It shows a message that "You're a developer now". * Then, open Developer Options and activate USB Debugging.
  • Connect your phone to the computer using a USB cable. It asks you for permission in your phone to "Whether you want to allow USB Debugging on the connected computer?". Press Allow.
  • Then reload the devices list and select your device using this button on the right top corner;

image

Building and Deploying Applications

We're providing two options for the developers who build applications using PythonFMXBuilder:

  • Option 1: Build an Android application (.apk) file. You can share your .apk file in your internal groups for reviews and validations. To do this, press on the Build button which generated .apk file in out\Win64\Release\apps\icon_splash\bin folder in my case.

image

  • Option 2: Deploy and launch the application to your device directly using the Deploy button:

image

You'll see your application open up automatically as you Deploy it in your device

You can iteratively develop for changes in your app and deploy to build your desired application

Clone this wiki locally