LiveCode and Android Studio
As of LiveCode 8.1.5 you can use Android Studio with LiveCode to set up Android deployment.
You need to download and install Java SDK version 8, if you already have Java 9 or 10 installed you will need to uninstall these and reinstall Java 8. You can download Java 8 here.
You will need to download the Android Studio SDK, here.
Opening the SDK Manager
Begin by starting up Android Studio.
LiveCode requires certain package to be installed. To open the SDK Manager, which allows additional packages to be installed select SDK Manager from the Configure menu on the Android Studio opening screen.
Installing the required packages
The Android SDK Manager lets you select the packages you would like to install in your Android development environment. By default, only a few packages are selected.
LiveCode requires the Android 4.0.3 (API 15) Package to be installed. From 9.0.1, you also need to select Android 8.0 (API 26). Select Android 4.0.3 (IceCream Sandwich) and Android 8.0 (Oreo) in the list and click the Apply button to install the package.
Note: you can see the Android SDK location at the top of the Window, take a note of this as you will need it in the next step.
Configuring LiveCode for Android Support
By now, you should have successfully installed the required software in your development environment. The next step is to launch LiveCode and configure it to interface with the Android SDK.
Launch the LiveCode IDE and select Edit -> Preferences to launch the Preferences menu. Then select Mobile Support and you are presented with the dialog shown in this step.
This dialog allows you to configure the path to the Android SDK root, which you should already have installed. Select ... under Android SDK and choose the folder containing the Android SDK root.
Validation checks are made once you specify the location of the Android SDK root. This ensures that you have selected a valid location and have the required Android components installed.
The following error message may be raised if something is wrong with your set up:
The chosen folder is not a valid Android SDK. Please ensure you have installed it correctly, and enabled support for Android 4.0.3.
This indicates that the path you specified is not pointing at the Android SDK root. You may have to navigate one level deeper into the folder hierarchy to access the root folder. The root folder may look something like: ...android-sdk-windows.
The Android SDK might have been installed into a hidden folder, meaning you can't browse to it. Showing hidden files and folders should allow you to browse to the SDK root.
Deploying to an Android device or Emulator
Now you have your LiveCode Android preferences set up you can deploy to an Android device or emulator.
Configuring a Virtual Device
Once you have installed the required packages, you can use the Android AVD Manager to set up a virtual device that can be used in your development environment. This allows you to test your applications without requiring a physical Android device.
To set up a virtual device:
- Open Android Studio
- Create a blank project
- Open the AVD Manager by clicking the AVD Manager button in the tool bar
- Select "Create Virtual Device"
- Follow the steps to create a virtual device. Remember that LiveCode can only use virtual devices with arm processors.
- Click the Launch button under Actions to start the virtual device.
Configuring a Physical Device
In addition to setting up virtual devices, it is possible to set up physical devices. These devices can be accessed after they have been appropriately configured for debugging.
Install the appropriate device drivers for the devices you would like to use. Details of how to do this can be found at the Android Developer Website.
The relevant device must be set to debug mode, once the necessary drivers are installed. To enable debug mode, please see your manufactures recommend instructions for doing so. An example for a Galaxy S3 running Android 4.1.1 is-
- Go to Settings > About > Software Information > More
- Now scroll to Build Number and tap it7 times repeatedly. After tapping the build number 5 times you'll see a message Press it two more times to be a developer and after tapping 7 times you'll see message You are now a developer or Developer mode has been enabled
- Navigate to Settings> Developer options
- Check option for Android Debugging
Testing on a Virtual or Physical Device
You should now have set up your development environment for Android and are ready to test a LiveCode application on an Android device.
Ensure the emulator is running or an adequately configured physical device is connected before trying to test your code. Then select a device from Development -> Test Target. The Test icon on the main pane of the LiveCode IDE should now be active and allow you to deploy your LiveCode application.
Note: When deploying to a device, you may receive a "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES" message. All this means is that there is currently an application installed on your device that has the same identifier as the app you are trying to deploy. This can happen if you are working on a specific app across multiple development machines.
To resolve this issue you can do one of the following
- remove the existing application from the device you are deploying to
- change the app identifier in the standalone applications settings