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.
Ensure you are running as Admin on Windows, or you may get a permissions error when trying to use your installed SDK.
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 SDK Platforms
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. Select the required package for your version of LiveCode. You can have other packages installed too, these are just the required packages.
- < LiveCode 9.0.1: ¬†Android 4.0.3 (IceCream Sandwich) - API 15
- LiveCode 9.0.1 - 9.0.5: Android 8.0 (Oreo) - API 26
- LiveCode 9.5.0 - 9.6.0: Android 9.0 (Pie) - API 28
- LiveCode 9.6.1+: Android 10.0 (Q) - API 29
Click the Apply button to install the packages.
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.
Installing the required SDK Tools
Android Studio 3.6+ has stopped installing the android command line tools by default. These tools were stored in the /Users/youruser/Library/Android/sdk/tools folder, and contained some necessary jar files that are needed to build for Android.
You can still use Android Studio 3.6+ to download these tools:
- Launch Android Studio and go to Configure -> "SDK Manager"
- Go to the "SDK Tools" tab
- Select "Android SDK Build-Tools"
- Select "Android SDK Tools"
- Click "OK" to download and install
- The "Tools" folder will appear in the /Users/youruser/Library/Android/sdk/ folder:
LiveCode 9.6.5+ requires Build-Tools v30+. It is suggested you install v30.0.3, since this version is extensively tested. If you are using an older version of LiveCode, then you have to install Build-Tools v27.0.3.
In the SDK Manager window, check "Show Package Details" to allow older versions to show.
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 LiveCode -> Preferences on Mac or Edit -> Preferences on Windows to launch the Preferences menu. Then select Mobile Support.
This dialog allows you to configure the path to the Android SDK root, which you should already have installed. Select the "..." button 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.
Then, the path to your Java Developent Kit (JDK) is auto-filled. If this is not the case, on macOS, try deleting the directory /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/ and then choose the Android SDK root folder again.
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 10.0.
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. The arm emulators are slow, so we recommend using x86.
- 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