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.

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-

  1. Go to Settings > About > Software Information > More
  2. 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
  3. Navigate to Settings> Developer options
  4. 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

33 Comments

Nelson

I tried configuring the Android SDK without luck. Installed Java in the same directory and the Android SDK and the same message appears. The Android SDK installed is the 4.0.3 using the Android Studio. The Java is the latest version. Any help on this?

Tom Bodine

Be sure you have LiveCode 8.1.5 or later. Older tutorial lessons have directions that may not work for the latest LiveCode. (You didn't say what error message you are getting, so hard to give specific advice.)

Christopher Flatt

Should this work on Mac OS X Sierra, with Livecode 8.1.4? I'm not having success here...

Panos Merakos

Hi all,

As Tom said, this lesson will only work with LiveCode 8.1.5 RC-1 or later.

Best,
Panos
--

Tom Bodine

Hi,
I have 8.1.5 (on Windows) configured with the Android sdk and java path is populated. And I've created a virtual machine with AVD Manager. However, the "test" and "test target" menu items remain grayed out, as does the toolbar's "Test" icon. What is the trick to making LC use an Android virtual device in LC 8.1.5?

Panos Merakos

Hi Tom,

You have to open a stack, and select "Android" in the standalone application settings. This should enable the "Test Target" and "Test" options.

Tom Bodine

Still not working. I tried two approaches:
1) Opened an AVD. Then opened LC 8.1.5 (rc1), opened a stack, selected only the Android build options, confirmed Android SDK selected in Preferences. But all "Test" options remained grayed out.
2) Reset test by quitting the AVD and LC. This time, opened LC 8.1.5 first. (All Test menus grayed out.) Confirmed Prefs > Mobile Support show the Android SDK and JDK paths. Confirmed Standalone App. Settings is checked only for Android build. ("Test" menus still grayed out.) Then opened Android Studio and launched AVD Manager, selected my AVD and launched it. AVD fully loads, but LC test menus remained grayed out.

Advice?

Tom

Panos Merakos

Hi Tom,

Hmm that's strange. Sometimes the "Test" button of the LC menubar is greyed out for me too (although I have the proper setup). However, if I just click on it, it is enabled. If you have not done this already, I suggest you give it a try.

BTW which version of Android Studio are you using? And how do you launch the AVD Manager?

Panos
--

Tom Bodine

Clicking the greyed Test icon does nothing. I have Android Studio 2.3.3. I launch my AVD from Studio using menu Tools > Android > AVD Manager. Then I launch my virtual device by clicking the green arrow under Actions.

Panos Merakos

Hi Tom,

I have exactly the same setup and it works as expected for me. I suggest you file a bug report at quality.livecode.com so as we can investigate this issue further.

Best,
Panos
--

Tom Bodine

Panos,
Are you using the 64-bit version of Android SDK or x86? Mine is the 64-bit. Wonder if that could be the issue.
Tom

Pablo Miranda

I follow all steps to install LC 8.1.5 and Android Studio. When i make a simple App for android, a button and 'hello world' i can't install it on a Xperia Z2. Always appear the message 'Analysis Error: An error occurred while parsing the package ' (Original message: 'Error de Analisis' 'Se ha producido un error al analizar el paquete')... Someone know where is the problem??

If do you want i can send you the project by e-mail!!

Thnak you!!!!

Elanor Buchanan

Hi Pablo

Firstly check your Android Standalone Settings and ensure you have the Identifier and Minimum Android Version set.

You may also need to enable USB debugging on your device.

I hope that helps.

Elanor

Elanor Buchanan

Just following up with another thought. If you are building a standalone and then copying it to your device you need to choose "Sign for development only" in the Signing section of the Android Standalone Settings. Alternatively, to test directly, you can connect your device, choose it from the Test Target in the Development menu and then use the Test button on the Menubar to test on your device.

Tom Johnson

Could someone please verify this lesson? I'm running LC 8.1.6 and Studio 2.3.3
I'm pretty sure I've followed the lesson correctly. The problem is I consistently get the error: could not encode class bundle. I get this when sending to the VM or building a standalone. I pretty sure I'm not the only one having this happen.

Thanks,
Tom

Elanor Buchanan

Hi Tom, I have run through the lesson here and can successfully build for Android.

Have you installed the Android 4.0.3 package? Could you let us know what OS you are on and what version of the JDK you have installed so we can double check. I am on Mac and have JDK 1.8 installed which works.

Thanks

Elanor

Tom Johnson

Hi Elenor,
Thanks for the reply. I have installed 4.0.3. and 2.2
I’m on a Mac running OS 10.12.6 with LC 8.1.6 stable
Android Studio 2.3.3

Java 1.8.0_144 is installed on my machine.
However, when I look at Preferences > Mobile Support it has 1.7.0_65 shown in the JDK Path. Is that installed by Studio?

Thanks,
Tom

Tom Johnson

Hi Elanor,
The problem I was having was that there was a previous Java folder in the Library folder and even though I have admin on my machine, the Java 8 144 install wasn't added to the existing folder. I renamed the existing folder and re-installed Java 8 144 and it build a new folder with the correct Java level in it. That fixed the Java problem. I don't get "could not encode class bundle" anymore.

I am getting another error however. Could you please explain how you have your Android VM configured.

Thanks,
Tom

Elanor Buchanan

Hi Tom, glad to hear you got that part sorted at least. What error are you experiencing now?

Kind regards

Elanor

Tom Johnson

Hi Elanor. When sending to the VM.
[INSTALL FAILED_NO_MATCHING-ABIS: Failed to extract native libraries, res=-113]
Here's a link to the discussion.
http://forums.livecode.com/viewtopic.php?f=53&t=29660

Thanks,
Tom

Elanor Buchanan

Hi Tom

This error is caused by an incompatibility in the architectures. I've tested 2 emulators here and the one with an x86 CPU/ABI doesn't work but the one with an arm64 CPU/ABI does.

Can you try setting up an arm64 emulator and see if that works?

Kind regards

Elanor

Tom Johnson

Hi Elanor,
Yes, the arm64 works but as I'm sure you know, it's agonizingly slow. So is this something LC needs to fix?

Regards,
Tom

Elanor Buchanan

Hi Tom

I've spoken to our Development Team and they confirm that we don’t currently support 64-bit ARM on Android, nor x86 (32 or 64-bit). The Android engine is armv6 only at the moment so this isn't a bug, it is expected.

You would probably find it much faster to connect up your Android device and test directly on that using the Development menu Test options. That's what we do here in the office as it's much faster than using Android emulators. You'll need to enable USB Debugging mode on your device.

I hope that helps.

Kind regards

Elanor

Craig P Wells

Hi Elanor,
I have encountered inability to get an app working on the latest Androids so I now understand that it is the 64Bit ARM issue (Galaxy S8) - it installs but just show a BSOD - black screen of death. WHEN will 64bit ARM support become available? Soon hopefully.

Craig

Heather Laine

I understand we are working on more and better compatibility with Android simulators, and yes, it should be soon.

Jim Burcicki

Hello,
In setting up the Android SDK, I have pointed to the SDK folder. However, the JDK: Path (none) remains the same. How do I get it to point to the JDK Path?

Elanor Buchanan

Hi Jim,

What version of Java do you have installed? If you are on Windows you will need to use Java 8 as LiveCode is not currently compatible with Java 9 or 10. If you are on Windows could you try downloading and installing Java 8. If that is not the issue please let us know, along with your OS and the version and edition of LiveCode you are using and we will look into it.

Kind regards

Elanor

Yasha

Hi Elanor

In regards to your answer to Jim that Java 9 or 10 is not compatible. If I have already Java 10 installed, do I need to uninstall it? How do I do it? After I install Java 8, do I need to reinstall the Android 4.0.3 package on Android Studio. I'm using a post 8.1.6 version of live code.

Thanks in advance
Yasha

Elanor Buchanan

Hi Yasha, yes, at the moment LiveCode will choose the most recent version of Java to use, do if you have Java 10 installed it will try to use that.

Depending on the version of Windows you have the uninstall steps differ slightly but this article explains how to do it.

https://www.java.com/en/download/help/uninstall_java.xml

I don't think you should have to reinstall the Android 4.0.3 package but you can check it is still installed by opening up the SDK manager in Android Studio and checking that it is ticked.

I hope that helps.

Kind regards

Elanor

John Iglar

I am having the same problem that Tom Johnson was having a year ago.
[INSTALL FAILED_NO_MATCHING-ABIS: Failed to extract native libraries, res=-113]
Is there support for all Android devices now? I'm using LC 9.0 My app saves as standalone and I've put it in the Play store for testing. My tester with Galaxy S8 (Android 8) says it can't install on his phone.

John Iglar

It seems that any Android developers will need a physical device to test their apps. There seems to be no non-x86 images available for Android Studio's emulator for Android 8. Play store requires 8.
(My tester got his version wrong. He was running 7, so couldn't install. Another tester with 8 installed OK.)

Elanor Buchanan

Hi John Iglar

We have been working on adding Android architectures and support will be included in 9.1.0 DP-1. I'm afraid I can't give you a timescale for the release of 9.1.0 DP-1 but you can add your email address to the CC list for the bug report to receive updates when the status of the bug is changed.

https://quality.livecode.com/show_bug.cgi?id=20954

Kind regards

Elanor

Sphere

That is really good news, did not see it before. Thanks Elanor.
Kind regards.

Add your comment

E-Mail me when someone replies to this comment