Skip to content

Step by step guide to create an Android application using PythonFMXBuilder

Priyatham edited this page Jun 3, 2022 · 6 revisions

Environment Setup

Now the environment to build an Android application is set

Project Setup

  • Press on the 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:

image

  • Add any supporting files that you use as part of your application's main.py code. 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 implementation in another Python files and call them from the main application Python file. Here, I added the frames_implementation.py file from our GitHub samples using right click on mouse>Add file;

image

  • 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.

Open/write your Python code

We have an option to open up a pre-existing Python code file into the code editing space. Currently, we've only a capability of just a notepad. We've plans to support basic code editing functionalities in future releases. So, our current suggestion is to write and develop your application in any other code editor and open it using the File>Open menu on the Menu bar.

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