How do I become an Android developer on Linux?
This lesson describes the basic steps you need to follow in order to start up as an Android developer using a PC with the Linux operating system. System configuration information and screen captures are provided.
The most recent version of the Android SDK tools do not work with LiveCode. If you are using LiveCode 8.1.5 or later please install Android Studio as described in this lesson.
Android is another mobile device family supported by LiveCode. The steps discussed in this lesson outline a process that allows you to set yourself up as a LiveCode developer for the Android platform on Linux and successfully build and deploy test applications. The steps are set out in chronological order, first determining the software requirements and then setting up your system.
Note: The screen captures are up to date at the time of writing this lesson.
You will need a PC that has the following software installed:
• 32-bit installation, or a 64-bit linux distribution that has a 32-bit compatibility layer
• 2.4.x or later kernel
• glibc 2.3.2 or later X11R5 capable Xserver running locally on a 24-bit display
• compositing window manager (optional - required for alpha-blended window shapes)
• gtk/gdk/glib (optional - required for native theme support)
• pango/xft (optional - required for pdf printing, anti-aliased text and unicode font support)
• lcms (optional - required for color profile support in JPEGs and PNGs)
• gksu (optional - required for elevate process support)
• mplayer (optional - required for video playback)
• esd (optional - required for audio playback)
Note: It is assumed that you are familiar with the installation process of a Linux operating system and LiveCode. Please make sure these are installed before you commence with the remaining steps of this lesson.
The following steps run you through the software installation process that you would typically follow on a PC.
Downloading and Install Java SDK (JDK)
The easiest way to install the Java SDK is through the terminal-
Open a new terminal window and type the following command-
sudo apt-get install openjdk-7-jdk
Now press return.
During the installation it may ask you for your password. This is perfectly normal and part of the installation process.
Downloading the Android SDK
If you do not have the Android SDK installed, then you can download it from: https://developer.android.com/studio/index.html. We would recommend the "SDK Tools" only download option.
Navigate to the download link that is specific to your hardware platform. You may get the kind of download dialog that is shown in this step.
Note: You can download older versions of the Android SDK Tools from this url:
where [rev] is the actual version. For example for version 20.0.3, the url becomes:
Installing the Android SDK
Extract the contents of the downloaded Android SDK to a directory of your choosing. In this lesson I have chosen the 'Documents' directory of my Linux Distribution.
Run the Android SDK Manager
Navigate to your Android SDK Directory and then to the 'Tools Directory' . Run the android script circled above
Installing the Android SDK Packages
This launches Android SDK and AVD Manager
The Android Package Installer lets you select the packages you would like to install in your Android development environment. In the screenshot above I have selected the Android 4.1 ,4.0 and 2.2 packages.
Note: Very old versions of Android are not supported and the very latest versions of Android may not be supported until LiveCode has been updated.
You will need the Andriod 4.0.3, API 15 or LiveCode will not recognize the sdk folder.
Verifying the Android SDK and AVD Manager Package Installation
After the Android SDK and AVD Manager has completed installing the selected packages, you should find that the status of packages has changed from 'Not Installed' to 'Installed'
Configuring a Virtual Device
Once you have installed the required packages, you can use the Android SDK and 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. You can set up a virtual device as follows:
1. Select Tools -> Manage AVDs from the Androids SDK Manager menu
2. Choose "Create" from the AVD Device manager window
3. Choose the Name for your virtual device.
4. Set the Target an installed Android API other than 8.
5. Fill in the SD Card Size.
6. Optionally enable Snapshot. This speeds up the launch of the emulator.
7. Select OK to create the AVD.
Starting the Virtual Device Simulator
You can launch the emulator by highlighting the virtual device you created and selecting Start... .
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:
1. Go to the home screen, and select MENU.
2. Select Applications -> Development and enable USB debugging.
3. Connect the device via USB to your development machine.
4. The device should now be available and accessible from the Development -> Test Target menu in the LiveCode IDE.
Configuring LiveCode for Android Support
By now, you should have successfully installed the required software in you 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.
You will aslo have to set the path to the JDK installation from earlier. In the case of my Linux installation the path is /usr/lib/jvm/java-7-openjdk-i386
The Standalone Application Settings... Window
Select File -> Standalone Application Settings... from the LiveCode IDE. Then choose Android from the list of deployment options. This raises the Standalone Application Settings dialog for Android specific builds.
You can make a stack build for Android by selecting the Build for Android tick box and configure any other options you wish to include.
You can select the name of your application using the General option at the top of the pane and add files to your build by using the Copy Files option at the top of the pane.
Note: Making a stack build for Android disables building standalone mainstacks for any other non-mobile platforms. If you wish to share code and resources among platforms, factor your application into multiple stacks, using a different mainstack for mobile and desktop targets.
Note: Inclusions, Copy Referenced Files, Bug Reports and Stacks features are not available when building for Android. Use the Copy Files feature if you wish to include multiple stack files in your application.
Note the option for signing. You can create and use a signing file following the directions here
create a key: keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048-validity 10000
sign the application using that key jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name (Note that alias_name may be anything but must be the same for both lines, and that obviously my_application.apk is the name of your app file.) but until that point you can change the option to "Sign for development only". This will avoid the [INSTALL_PARSE_FAILED_NO_CERTIFICATES] error.
Running Under Android
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 the LiveCode IDE from Development -> Test Target. Your Test icon on the main pane of the LiveCode IDE should now be active and allow you to deploy your LiveCode application.
NB When deploying to a device, you may recieve 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 your 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 too
-change the app identifier in the standalone applications settings
Also, note that as of Android 5.0, ADB 1.0.32 is needed to communicate with a device. Since the default adb in /usr/bin is 1.0.31, you will need to upgrade it following the directions here
Depending on how experienced you are with LiveCode, you may want to review more of the numerous lessons and tutorials we have on developing for Android, iOS and broader lessons that explore the general concepts behind LiveCode. The release notes accompanying LiveCode releases with Android platform support provide up to date development information and give you an overview of the features that you can access via LiveCode.