-
Notifications
You must be signed in to change notification settings - Fork 14
Step by step guide to create an Android application using PythonFMXBuilder
- Download, Install, and set up the Android SDK using the following wiki guide: https://github.com/Embarcadero/PythonFMXBuilder/wiki/Android-SDK-guide
- Download, Install, and set up the Java JDK using the following wiki guide: https://github.com/Embarcadero/PythonFMXBuilder/wiki/Open-JDK-guide
- Leave the Debugger Settings as they are, which will be filled automatically:
Now the environment to build an Android application is set.
- 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:
- 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
andframes_main.py
files from our GitHub samples using right click on mouse > Add file on the right-sided Project explorer window. Here, the main application file isframes_main.py
;
- You can open the files in the editor area by double-clicking the above added files;
- Update the project settings by going to Project > Update Project:
- It opens up a slider window from the right edge 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:
- Provide the version information in the Version Info section. It depends upon your release schedule information.
- Let's set up the main file that can be used to run our application in the Initialization Script Setting section. Here, we're setting the
frames_main.py
to the main file from our two script files.
- We're shipping 3 Python versions -
3.8
,3.9
, and3.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 the Python Settings section. We also support building apps on both 32 (arm
) and 64 (aarch64) bit arm architectures.
- You can set the app icon and splash screen (app start screen) image using the Application Icons section. Based on the device screen sizes and screen densities, FMX Builder will choose the image size of your splash screen and icon. You can upload all those sizes to support all screen sizes and resolutions.
Note: After setting all these Project options, press the Save button at the bottom.
First, you need to activate USB Debugging on 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 on your phone to "Whether you want to allow USB Debugging on the connected computer?". Press Allow.
- Then click on the reload button to load list of devices and select the first device using this "Load Devices" button on the right top corner;
We're super excited to say that the FMXBuilder application supports most of the debugging features of modern-day IDEs.
Note: For debugging functionality to work, you need to install the TMS FMX UI pack. You can find it at: tmssoftware.com/site/tmsfmxpack.asp. Otherwise, you can build the raw Memo editor version provided in our release at Release v0.7.0 - Embarcadero/PythonFMXBuilder.
- For debugging, you can set breakpoints at any part of your code by clicking on the line number wherever you want to debug and investigate.
- Click on the Debug Project button to enter into debug mode and start debugging the application.
- In the debug mode, multiple windows to support debugging will be opened. They are:
- StackTrace
- Local Variables
- Events
- Breakpoints
- Threads
- You can use the multiple controls that are activated in the Debug mode. You can use them to navigate through the debugging process. Each button's functionality is self-explanatory.
- After you're satisfied with your debugging, you can press one of the Stop or Continue buttons of the above buttons to finish the debugging process.
We're providing three options for the developers who build applications using PythonFMXBuilder:
y
-
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 generates the.apk
file inpath\to\FMXBuilder\GUI\Folder\apps\Frames\bin
folder in my case.
- Option 2: Build and *Deploy the application to your device directly using the Deploy button:
- Option 3: Run button will implement both Build, Deploy and Run (Launch) your application at once so that your app opens up as it launches.
You'll see your application open up on your device or emulator automatically as you Run it. You can iteratively develop for changes in your app and Run to build any Android application of your choice.
Embarcadero Python-Dev Team