Blog

All Blog Posts  |  Next Post  |  Previous Post

Exploring Windows 11's Android Integration: Testing FNC Apps with Windows Subsystem for Android

Bookmarks: 

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.

TMS Software Delphi  Components

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.

TMS Software Delphi  Components

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:

  1. Access the environment variables settings.
  2. Edit the "path" variable and append the folder path where adb.exe is installed.

TMS Software Delphi  Components

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.

TMS Software Delphi  Components

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. 

TMS Software Delphi  Components

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.

    TMS Software Delphi  Components


    Get Started now

    TMS Software Delphi  Components

    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 accessibility—explore, create, and conquer with us today.



    Bradley Velghe


    Bookmarks: 

    This blog post has received 2 comments.


    1. Friday, December 22, 2023 at 1:53:57 PM

    Wow, this is a very interesting article about testing Android Apps with no special emulator needed! Thank you for Sharing this information and instructions to us - a big time saver!

    Hindermann Thorsten


    2. Friday, December 22, 2023 at 2:45:43 PM

    I have now tested it with my own little FMX app. The complete process with under 5 minutes I have my own FMX app running in the WSA! That''s incredible wonderful experience. A few lines above in the instructions I think you must change 192.0.0.1 into 127.0.0.1 ;-).

    Hindermann Thorsten




    Add a new comment

    You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
    All fields are required.



    All Blog Posts  |  Next Post  |  Previous Post