Blog
All Blog Posts | Next Post | Previous PostExploring Windows 11's Android Integration: Testing FNC Apps with Windows Subsystem for Android
Thursday, December 21, 2023
Remember when you had to install emulators to run Android apps on Windows? Not anymore with Windows 11! It now has Windows Subsystem for Android, letting you use Android apps like they're made for Windows.
We got curious and tried this feature to see if it works with apps made using FNC. In this blog, we'll show you how to set it up so you can test your apps without needing an emulator or an actual Android device.
Prerequisites:
To follow along with this guide, ensure you have a Windows 11 system as this is required. We tested this on Delphi 12, other versions might not all be supported.
Windows Subsystem for Android
The initial step involves setting up the Windows Subsystem for Android (WSA). Begin by downloading the Amazon Appstore from the Microsoft Store. Presently, this remains the only official method to install WSA. Once the Amazon Appstore is installed, locate WSA in the Windows menu.
Launch the software and navigate to advanced settings. Enable Developer mode. Take note of the displayed information indicating that ADB can be connected via an IP address. Copy this IP address as it will be required later.
Android Debug Bridge
Subsequent steps entail establishing a connection with WSA, enabling us to target it from Delphi. Begin by downloading the Android SDK Platform Tools. Unzip the package and place it in a convenient location on your system.
To connect to WSA, open the Command Prompt in the directory containing adb.exe. Alternatively, for convenience, add the folder path to your system's Environment Variables, allowing you to use ADB from any location without specifying the full path to the executable.
To add the folder path to your system's Environment Variables:
- Access the environment variables settings.
- Edit the "path" variable and append the folder path where adb.exe is installed.
In the Command Prompt, execute the following command using the previously copied IP address from WSA:
adb connect 127.0.0.1:58526
if you encounter the following error message:
cannot connect to 127.0.0.1:58526: No connection could be made because the target machine actively refused it. (10061)
Launch WSA, access the System section, and open the Files. This action will initiate the Subsystem. The error occurs because the Subsystem requires an app to be running or opened.
Retry the command in the Command Prompt & you should now receiver the confirmation:
connected to 127.0.0.1:58526
WSA should now appear in RAD Studio when targeting Android, resembling a regular device. You're all set to deploy FMX applications to this system.
note: We have used the OpenChargeMap demo from TMS FNC Maps to test everything.
Deploying
When deploying, it is important that you pay attention to the following points
- For 32-bit, you should be able to deploy, without needing to resort to external commands. This should work out of the box from RAD Studio.
- For 64-bit, you'll need to build the apk without installing it. Open cmd in the folder where the apk is located and execute the following command:
adb install test.apk
- For older projects, it might be necessary to revert the system files to default. Just right click on the libraries in your target platform and you should see the option appear. When creating a project from scratch, you can just skip this step and it should work.
- If you have used a browser-based component, please don't forget to add the necessary JAR-files (WebChromeClient & JavascriptHelper). If you have gone through these steps, you can now just run the application and you should see it starting.
- Regrettably, our attempts to enable debugging were unsuccessful, resulting in the absence of error messages when the application crashed. Consequently, we had to reboot the ADB connection whenever this occurred.
- If you deployed with debugging enabled, it might happen that you get a LLDB error, you can just ignore this. The application should work fine.
You can now even open the application, through your windows menu. It will even show up in your installed apps, just like a regular application. Nothing hints that this is, in fact, an android application running in windows.
Get Started now
Unlock boundless opportunities with TMS FNC Component Studio and our suite of FNC Components! Seamlessly harness the power of this cutting-edge technology to deploy across all platforms effortlessly. Amplify your potential with TMS ALL-ACCESS, your gateway to discovering the full spectrum of what we have to offer! Reach new heights in innovation and accessibilityexplore, create, and conquer with us today.
Bradley Velghe
This blog post has received 2 comments.
Hindermann Thorsten
All Blog Posts | Next Post | Previous Post
Hindermann Thorsten