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 JDK 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 also need to download Android Studio, here.

Ensure you are running as Admin on Windows, or you may get a permissions error when trying to use your installed JDK. On recent MacOS versions, you might need to go to System Settings and whitelist the jdk binary to allow it to run.

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.

  • Versions older than 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 - 9.6.5: Android 10.0 (Q) - API 29
  • LiveCode 9.6.5 - 9.6.8: Android 11.0 (R) - API 30
  • LiveCode 9.6.9 : Android 12.0 (S) - API 31
  • LiveCode 9.6.10 : Android 13.0 - API 33
  • LiveCode 9.6.13 & LiveCode 10 RC-1: Android 14.0 - API 34

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, or v31.0.0 since these versions are 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.

Note: Do not install any other version newer than 31.x.x, since these are not currently supported

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-

  1. Go to Settings > About > Software Information > More
  2. Now scroll to Build Number and tap it 7 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

If you still have trouble setting LiveCode up for building Android standalones, consult the Livecode Android Studio Setup Checklist.

121 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.

Acch

Hello! I am trying to use the LiveCode v9.0.1 on my windows 10 system. I could not build my application into my android device even though I have followed this forum closely : https://forums.livecode.com/viewtopic.php?t=31288
The error I got was "Unable to build app for testing: apk preparation failedUsage: java"
The Java version I have is "jdk1.8.0_181" I have cleared the excess files in the Java folder and I could not figure out this issue. I did not encounter such issues on v8.1.3 before. I was able to build it on that version. I really hope I can build it into my android device.
Thanks

Elanor Buchanan

Hi Acch

From LiveCode 9.0.1, you also need to have Android 8.0 (API 26) installed. You can install this using the SDK Manager as described above.

If you already have Android 8.0 installed and you still cannot build please let us know and we will look into the issue further.

Kind regards

Elanor

Rhianna

I have a problem with LiveCode finding the valid Android SDK root. I followed the directions and have the avdmanager and sdkmanager in the my_sdk folder that also has the tools folder. I also have run them and it created a file called knownPackages in that folder. When I try to point LiveCode to the SDK root, it also says I don't have Android 8.0, but Android Studio (through the SDK manager) says I do have it. Am I missing a step? Anything will help!

Elanor Buchanan

Hi Rhianna,

What version of Java do you have installed? 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.

If that is not the issue please let us know, along with your OS and the version of LiveCode you are using.

Kind regards

Elanor

Tony Santa Cruz

I am currently using a Macintosh OS X 10.3.6 and using LiveCode Community 9.5.1 (rc 1) to and trying to create a standalone application for Android.

I have selected the includes and all. Have made sure I have the preferences pointing to the correct Library file for the Android SDK (similar to the example in the article). Made sure all the proper files are installed for the Android SDK.

Livecode just gets stuck on Checking directories in the Standalone Builder Progress and never proceeds beyond that.

Have been trying for days and getting nowhere.

Elanor Buchanan

Hi Tony

I have just tried a very simple Android app here with the same setup and it built ok. Can I ask if you could build Android apps in 9.5.0 and this is a recent issue that affects 9.5.1? Also what inclusions do you have selected? Perhaps one of the inclusions is causing the issue, could you try with a very simple stack and see if you can build that successfully?

Thank you.

Kind regards

Elanor

Tony Santa Cruz

Hello Elanor,

Thanks for the response.

I did as you instructed and used a tutorial stack that I downloaded and was able to get it to convert to a standalone application for Mac and Windows without any issue. However, when I try to get it to convert to a standalone for Android, it gets to Attaching Engine and just I get no response afterwards. It never finishes. This is using LiveCode Community 9.5.1 (rc 1).app.

I have not been able to get an Android standalone app created since a 4.0 version of LiveCode. I have earlier versions and really need to get the latest version working as it has PDF reading capabilities that I really need for my App.

Atleast it doesn't get stuck on the inclusions part with the tutorial stack.

Panos Merakos

Hello Tony,

Could you post a screenshot (so as we can see the contents) of the folder that is is chosen as the android sdk root folder? Also could you post a screenshot of your Preferences -> Mobile Support?

It sounds like something is incorrect in your setup.

Kind regards,
Panos
--

Jana

I'm struggling to compile for Android on Ubuntu 18.04 LTS. I can compile on a Windows machine, so I'm looking for pointers. I'm using LC 9.5. Under Preferences > Mobile Support the Android SDK is correctly entered, and the JDK points to /usr/lib/jvm/java-8-oracle which I understand to be correct. However, when I try to compile, I get stuck when 'building classes' and get a 'could not compile service support class' error. I have re-installed Java, Android Studio, and LiveCode to no avail.

Elanor Buchanan

Hi Jana

What is your application identifier set to in the Android Standalone Application Settings? If it is not correctly formatted the service support class will fail to compile.

The rules are
- It must have at least two segments (one or more dots).
- Each segment must start with a letter.
- All characters must be alphanumeric or an underscore [a-zA-Z0-9_].

If that is not the issue please let us know.

Kind regards

Elanor

Jana

Dear Elanor. Thanks for the fast response! The application identifier in the Android Standalone Application Settings is the common "com.jana.app" style, thus not a problem. I can compile the same stacks on the Windows machine that seems to be setup the same way. I get the same error if I create a new stack, too.

Elanor Buchanan

Hi Jana

Sorry for the delay in getting back to you. This error might be occurring because of the version of Java you are using. We have tested and the openjdk version of Java works for us here, could you try this instead of the Oracle version. An example of the jdk path that works for us is

/usr/lib/jvm/java-1.8.0-openjdk-arm64

I hope that helps.

Kind regards

Elanor

matins

Unable to install SDK. It keeps bringing me to this site where I have to either sign in to and a account or make an account... I clicked make an account and had to enter my name, postcode, job, business line, phone line, which am to young for.

Heather Laine

You can download Android Studio without providing any personal information. I expect you do need to provide more information to create an Apple Developer or Google Play account. Perhaps you can get an adult to do this for you?

NN

Panos forgot to add: For all "first time users" who want or have to start with Android Studio > 3.1 and LC > 9.5 , they have to install also the included sub-packages ref to each SDK (eg Pie) + Legacy support as explained by Panos in this DOC... otherwise some parts the Android SDK/API will be missing and the LC IDE will recognise neither the Android SDK nor the Java JDK! SO in Android Studio (start screen) go to configure > Android SDK > select the Version and activate "Show Package Details" !!! - just select all for each Version (I didn't wanna waste my time with finding out what part is missing - so in the interest of time I picked them all). Just a friendly reminder to the LC MGMT - if you advertise your product as truly X-platform - you must get your docs right "on time" - you must not say - oh Apple did something with Xcode in the new version where we struggle with same for Oracle Java and Android... I truly understand you can't pick all battles with 3rd party interfaces BUT you must share the details with your clients !!! !!! !!! in a timely manner !!! !!! !!!

Heather Laine

In the lesson, we say:

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 - LiveCode 9.0.5: Android 8.0 (Oreo) - API 26
LiveCode 9.5.0+: Android 9.0 (Pie) - API 28

These are the required packages of the Platform Tools that are needed for building an Android standalone. So if you are in LC 9.6 DP-4, you will only need the Android 9.0 (Pie) - API 28 platform tools from this tab. What you suggest, i.e. to:

"activate "Show Package Details" - just select all for each Version"

will install all the possible versions of the android system images, which means all the possible versions (and architectures) for the Android simulators. This is clearly not necessary, and apart from that, the "system images" packages need several GBs to be saved. It is better to select the individual package that is required.

yahli zvyfler

i download the virtual devices and it works but i dont see him on the test target i have android studio 3.6 and community 9.5

yahli

hey
i don"t see the option to "android sdk tools (obsolete)" and i Uncheck the hide obsolete packages.
and i cant see the sdk in the /Users/youruser/Library/Android/sdk/ i dont have Library in the android studio i see that in a AppData and i dont have a folder that called app data
thank for helping

Heather Laine

If you are on Windows, then you will have your SDK in AppData. You need to make this folder visible by choosing "show hidden folders". Then you should be able to select it from LiveCode.

Heather Laine

your virtual device should appear in test target once you have set the path in LiveCode to your Android SDK.

Heather Laine

Make sure you have also checked at least one arch for in the LiveCode Standalone settings for Android so that building for Android is enabled.

Kim

My computer died a few days ago and I needed to do a factory reset & re-install LC. FYI:
- The lesson is correct, except that, with Android Studio 3.6.3, it is "Tools menu" not "Configure menu"
- Also, Android Studio forced me to create an SDK folder, and was very pedantic about where I could create it and how I could name it
- upon install Android Studio gave me a bunch of error messages about "Gradle". No idea what this is, but I managed to successfully deploy a standalone onto an Android device so I'm guessing that it doesn't matter for LC purposes

Thanks for the lesson

Peter

Hi ,
new to livecode , as experienced programmer.
- windows install :
ok, but ide is soooooooooooooooooooooooooooooooooooooooooooooooooooooo
slow.....
- the ide windows are horribly place and jump all over the place
- icons are hardly readable , what gives, are we still in 1990 or 2020 ???
ok , then trying the linux distro
- cannot install for all users , if installing for 1 users, getting error when trying to open dict. window
- ide , poor , same as windows

- it seems the people that are "really" using it , are using macos

- this is not a new product , and still a pain to install ,and an ide that sucks in windows and linux

- do you really want to increase your user base or what ????

regards,

Peter

Mark Wieder

Peter, not a Windows user, so I can't comment on that part.
On linux, installing for all users will install into /opt, so you need permissions to do that. I don't have those problems with the IDE - it's responsive and the dictionary opens in a web browser. If you're installing an older build then it may be trying to use a CEF browser to open the dictionary, which will indeed result in an error.
Are you installing the latest build?

Matthias Rebbe

Peter, there were reports from users who had similar performance problems under windows with Microsoft Defender active? Is it possible by any chance that you are using Defender as your security software? If so, you could try to exclude Livecode .exe file and the my livecode folder from realtime scanning in Defender.

Pradeep Saxena

I have 9.5.1 LC indy, MacOS High Sierra (10.13.6) and using MapKit for iOS & Android. Got the google Map sdk API working on the Android simulator. The MapWidget works fine with the markers etc. on the Android/iOS emulators and MacOS. The generated apk installs on Samsung G8 but crashes on the MapWidget screen. The app identifier is updated and also the app is signed with a keystore file. The google map API is working for the widget to work on the Android Emulator. What am I missing to make it work on the Android phone? Same issue using LC 9.6

Elanor Buchanan

Hi

Have you added your Google Maps API key in the Inclusions pane of the Standalone Application Settings? In the General Pane choose "Select inclusions for the standalone application, in the Inclusions pane tick the Map widget and click on the cogs to add your API key. You will also need to make sure any other inclusions you are using are ticked.

I hope that helps, if that is not the solution please let us know.

Kind regards

Elanor

Pradeep Saxena

Hi Heather,
I did add the Google Map API key and that's the reason why it works on Android Simulator (without the right API key, it does not work in Android Simulator). The fastest way to resolve this would be to send me a basic working livecode script with map widget for Android device and I can use my GoogleMapAPI key to validate it on an Android device.

Thanks,
Pradeep

Elanor Buchanan

Hi Pradeep

You can download my test stack from this link, you will need to add your API key.

https://downloads.livecode.com/learning/techsupport/MapTest.livecode.zip

I testing on an Android phone running 7.1.1 and I tested with both signed and unsigned apps. What version of Android is your test device running?

Kind regards

Elanor

Pradeep Saxena

Hi Elanor,
Thanks for providing the test stack. Though, it did not help resolve the issue, but I think I discovered understanding couple of other issues: 1. Your stack did not work in my environment as is. It kept crashing on Android simulator and Android phone (9.0). Surprisingly, when I created an identical new stack in my LC indy 9.5.1 with the same map api key, it worked on the Android simulator, but not on device!! This helped me discover the reason why my working map widget stacks in LC business on simulator stopped working on LC indy (though identical LC version 9.5.1), all because of the map widget issue. Once I recreated the fresh map widget stack and copied the code, it started working on the Android Simulator! 2. The MapWidget bug reported on April 14,2019 still persist (https://forums.livecode.com/viewtopic.php?f=104&t=32479) as the Visible property toggle of MapWidget crashes the app in the simulator! Perhaps the map widget may work on my android device while generating the apk on windows/linux desktop (will try and let you know). Please provide answers to following:
1. What is your environment? Desktop OS & LC version for the provided Test Script.
2. What is the possible reason that your test stack did not work as it is, but worked as expected in the simulator only when I recreated it in my environment with the same map API
3. I am using the Google Map Android SDK api (There are 15 different Google Map APIs), Is this the correct one? If not which is the correct one, but then why should the widget work in simulator using this API?
4. My app release is delayed only because of the MapWidget issue in Android device. Please help resolve this at your earliest.

Thanks for all the help in advance,

Pradeep

Elanor Buchanan

Hi Pradeep

I have uploaded a new version of the test stack to

https://downloads.livecode.com/learning/techsupport/MapTest2.livecode.zip

There was some information left in the stack connecting it to my API key which I have removed. This is why my stack did not work on your environment but a recreation did.

We have also found an issue with the Map widget on Android 9 devices, which we think is why it is working in the simulator but not your device.

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

You can work around this by adding the required key to the manifest template in

/Applications/LiveCode Business 9.6.0.app/Contents/Tools/Runtime/Android/Manifest.xml

Add

just before the closing tag:

I hope that helps.

Kind regards

Elanor

Roger Mepham

Success first time! Followed instructions above and am now seeing an Android app running on the emulator.
Notes:
1. Running on MacBook Catalina 10.15.6 with Livecode 9.6.1
2. Installed Java 8 first
3. Installed Android studio using "Recommended options" in installer, note that Android SDK Tools (Obsolete) was already ticked and installed so no need to configure.
4. Selected API 29 Android 10 (not the latest 10+ which I had to change)
5. Livecode accepted the path to the Android tools in preferences
6. In Android studio started an empty project and configured a Pixel 3 virtual device and started it.
7. Opened a new Livecode iPhone 6 project size and configured the standalone as Android with a "Sign for development only" choice
8. Selected Android emulator as the target for testing in Livecode

Built and run first time - woohoo!

Bernard

After following the Lesson I got the "JDK path: none" error on both OS X and Windows. I've written up an explanation as to why this error occurs and what LC can do to remove this frustrating problem for users.

a) Lesson is wrong (JDK not needed since Android Studio 2.2)
b) LC Prefs goes the wrong way about finding installed JDK

A few small changes by LC and the lives of those getting LC to work with Android Studio will be a lot easier.

https://forums.livecode.com/viewtopic.php?f=53&t=34837

Panos Merakos

Hello Bernard,

Thank you for the detailed forum post. We will review the changes suggested there, and update the lesson.

Kind regards,
Panos
--

Michael

I am trying my first Android and I have the emulator all set and when I get to TEST i get stop sign with "Unable to build app for testing: could not compile service support class". Please help

Heather Laine

Have you checked that you have Java 8 and only Java 8 installed?

Richard Gaskin

Is the separate JDK download still needed? I thought the Studio SDK was sufficient, no?

Are we confident this recipe works? It's been cited as a source of confusion and frustration in the forums.

Panos Merakos

@Richard

A separate JDK download is probably not needed anymore. You should be able to choose the JRE folder that is bundled in Android Studio, as Bernard described in the forum post that is linked to the previous comment. We need to update the lesson. The reason it has taken so long is that we have to review and adapt the suggested changes for all 3 desktop platforms. Or ideally tweak LC's mechanism to detect the JRE folder automatically on each platform.

Kind regards,
Panos
--

Howard Firkin

Followed instructions carefully. Cannot get past Location of Android development SDK root. Tried every directory under the directory listed in Android Studio as the SDK location but continue to get "The chosen folder is not a valid Android SDK." error message. Hugely frustrating.

Elanor Buchanan

Hi Howard

I am on Mac and my SDK location is

/Users/elanorb/Library/Android/sdk

You can also see this in the "Android SDK Location" field in the SDK Manager in Android Studio.

What OS are you on? Which SDK Platforms and SDK Tools do you have installed in Android Studio?

Thanks

Elanor

Bernard

Howard, Eleanor over the forum we have recently had two different people where Android Studio was missing files (one was on Linux, the other on Mac).

Howard Firkin

Elanor, thanks for the reply. I'm on Windows 10. According to the SDK Manager the SDK location is C:\Users\firkin\AppData\Local\Android\Sdk, but when selected in Livecode 9.6.3, the irritating message appears. Tools: I have Android SDK Build-Tools 31, Android SDK Command Line Tools (latest), Android Emulator, Android SDK Platform-Tools, Intel x86 Emulator Accelerator, Android SDK Tools (Obsolete) installed.
Platforms: 10.0, 9.0, 8.0, 7.1.1, 4.2, 4.1, 4.0.3

Elanor Buchanan

Hi Howard

Could you try removing Build-Tools v31 and installing v27.0.3 . You can check "Show package Contents" to allow older versions to show.

We have reported a bug

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

Kind regards

Elanor

Elanor Buchanan

Hi Bernard,

Panos has reported a bug

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

I think this covers the missing files issue you mentioned above. Thanks for bringing that to our attention.

Kind regards

Elanor

Howard Firkin

Elanor and Bernard, thank you for your help. This has solved the problem. I appreciate how difficult it is to be expected to have expertise in systems for which you have no responsibility. So thank you both.

Elanor Buchanan

I'm glad to hear you have it working now. I have added a note to the lesson and the Development Team are investigating.

Kind regards

Elanor

Charlie

Hello! This comment thread has been very helpful. I removed Build-Tools v31 and installed v27.0.3, but my app still crashes when I try to open a page with a map in the Android Studio emulator. I'm using LiveCode Indy 9.6.2 on MacOS Catalina 10.15.7 with Android Studio Arctic Fox 2020.3.1 Patch 2. My virtual device is a Pixel 4 API 29 (Android 10 Google Play).
I recreated the MapTest app that Elanor provided, adding my own map key. If I don't include Map in the standalone settings, the app loads in the Android emulator, but when I do include the Map (with my own map key) in the inclusions, the app crashes when opened in the emulator.
Another issue I'm having with the "real" app I'm building for Android is that it contains a data grid that has images and the images in the data grid are not showing in the Android emulator. The images are in a database which I've attached to the stack using "copy files" in the standalone application settings. The images appear in other parts of the app when tested in the emulator, but not in the data grid and not on the pages where the users have to click on the data grid to see a larger version of the image on another page in the app.
I've searched the LiveCode Forums and Lessons but see very little about data grids and Android. Everything works fine on the iOS version of this app but in the Android version, I'm having issues getting the images to display in the data grid and with the map (that includes markers) to even load correctly in the Android Studio.
I always think there is a simple thing that I'm missing to get things working properly, hope that's the case in these instances too, so any tips or suggestions would be greatly appreciated. Thanks!

Doug

Hi all. I too am unable to build an Android standalone in LC; after overcoming several obstacles with help from several LC forum posts, I'm getting the dread "could not compile service support class".

I'm on Linux Mint 20.2, with Android Studio Artic Fox 2020.3.1 Patch 2. I'm able to build Android apps and deploy to the Android simulator using AS. I've tried LC 9.6.4 and the 9.6.5 RC - no dice. I'm able to configure LC with the AS SDK and JDK locations; the only weird thing is that because I used Flatpak package manager to install AS, its bundled JDK gets installed into a long-named directory that looks like this:
/var/lib/flatpak/app/com.google.AndroidStudio/x86_64/stable/f9a6672c8e1f4c8bb1a4282f417c759cf5fc4f64fdfc716b7809111fa7e0aafd/files/extra/android-studio/jre

But LC accepts this JDK path, and looking in that directory I see and can run java executables.

I'd appreciate any help getting past this (hopefully last) hurdle!

Elanor Buchanan

Hi Charlie,

It sounds like you might be experiencing this bug, does your case sound similar?

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

As for the images in the DataGrid is it just the display of the image in the DataGrid that is an issue or is it the retrieving of the image from the database? I would suggest checking the image data you get from the database when populating the DataGrid. It is hard to know what is wrong if it works as expected on iOS and the images appear elsewhere so all I can suggest is to check at which step the issue appears.

Kind regards

Elanor

Panos Merakos

Hello Doug,

What is the version of your SDK Build-Tools?
Regarding the (vague) error "could not compile service support class", a way to get more info out of it is the following:

1. Type in the msg box:
put true into gRevDevelopment

This will ensure that any breakpoints added in IDE stacks will be respected.

2. Type in the msg box:
edit the script of stack revsaveasandroidstandalone

3. This ^^ should open the script editor in said script. Search for "could not compile service support class"

4. Replace this:

if the result is not empty then
throw "could not compile service support class"
end if

with:

if the result is not empty then
put CR & the result after msg
throw "could not compile service support class"
end if

5. Hit Apply to save your changes, and then try to build an Android standalone again. Hopefully now you should get a more descriptive error in the msg box.

6. Post the new full error here, and we will investigate further.

Doug

Hi Panos, thanks for the reply. I got it working, had to download Java 8 from Oracle.com even though I already had a Java v8. No idea why the one worked but the other didn't.

Your reply is very informative as to how to do things "under the hood" in LC, though - thanks again!

Charlie

Hi Elanor,

As for the images in the DataGrid, I’m trying to figure out if it’s the retrieval of the images from the database that’s causing the images not to display in the DataGrid.

In my DataGrid group, I am using the GetDataOfLine function to test what is being retrieved from the DataGrid array. However I'm not sure how to test the array that holds the images (taken from a database). For example, to test the array that holds the address, I have (in the script of “group DataGrid 1”):

put the dgHilitedLines of me into theLine
answer GetDataOfLine(theLine, “address”)

The result is the correct address associated with that line in the DataGrid. But to test for the image(s), I get a result that says “aPNG” for each row I click (the DataGrid has 50 rows). This is the code I used to test if the images are being retrieved properly:

put the dgHilitedLines of me into theLine
answer GetDataOfLine(theLine, “image URL”)

To set the dgData Property, I have

command uiPopulatePeople
local tImageData

put specialFolderPath(“documents”) & “/test.db/“ into tDatabaseFileName

put “383 West Broadway” into theDataA[1][“address”]
put “various descriptions” into theDataA[1][“info”]
put databaseGetImage(1) into tImageData
put tImageData into theDataA[1][“image URL”]

set the dgData of group “DataGrid 1” to theDataA
end uiPopulatePeople

Hopefully this makes some sense. Bottomline is that once I test the app in the Android Studio on an emulator, none of the images that are called when the user touches the DataGrid are showing. Everything thing works fine in the iOS version and in the LiveCode IDE.

Elanor Buchanan

Hi Charlie

It sounds like the image data is there in the DataGrid so it is a display issue. The “aPNG” you get when you test is the start of the binary data representing the image.

I assume you have an image control in the row template and you are setting the text or imageData of the image control?

I can't think of any reason this would work in the IDE and on iOS but not Android.

Do you have a physical Android device you could test on in case it is emulator specific?

Kind regards

Elanor

Charlie

Hi Elanor,

I tested on a physical Android device and still have that same issue with images not displaying in the DataGrid or off of actions from the DataGrid on the Android device or Android Studio emulator.

I am setting the image control in the row template to the text of the image. In the FillInData handler I have:
set the text of image "image" of me to pDataArray["image URL"]

This is what I have on the card that contains the DataGrid and I’ve copied the correct file in the standalone application settings:

command uiPopulatePeople
local tImageData
put specialFolderPath("documents") & "/soho.db/" into tDatabaseFileName

put "1" into theDataA[1]["number"]
put "383 West Broadway, 1868" into theDataA[1]["address"]
put "John Q. Public, architect" into theDataA[1][“architect"]
put “descriptive information" into theDataA[1]["info"]
put databaseGetImage(1) into tImageData
put tImageData into theDataA[1]["image URL"]
put databaseGetImage(48) into tImageData
put tImageData into theDataA[1]["display URL”]

lock screen
set the dgData of group "DataGrid 1" to theDataA
set the dgHilitedLines of group "DataGrid 1" to 1
unlock screen
end uiPopulatePeople

And this is what I have in the script of group “DataGrid 1”:
on mouseUp
local gHilitedLine, gImageData

put the dgHilitedLine of group "DataGrid 1" into gHilitedLine
put the dgDataOfLine[gHilitedLine] of group "DataGrid 1" into gImageData

set the cImageInfo of card "display" to gImageData["info"]
set the cImageFilename of card "display" to gImageData["display URL"]

lock screen for visual effect
go to card "display"
unlock screen
end mouseUp

When I test on the physical Android device, the first time the app opens and I go to page “Display”, the image that was on page “Display” in the IDE, appears in the app, but doesn’t appear again if I leave the page and return. Again, everything works fine in the LiveCode IDE and in the iOS version of the app.

Heather Laine

Charlie, I think in order to help you any further with this we'd need to see your stack. It then becomes a technical support incident and you would need a contract with us to debug it. If you want to pursue this could you email [email protected] and I'll assist you to purchase the appropriate product? A final hint we can offer: you probably have an implicit string->binary conversion somewhere in your code.

JereMiami

Switching to 9.6.5 gives me an error
-- Unable to build app for testing: could not encode class bundle - compilation failed with an internal error
java.nio.file.invalidpathexception: illegal path chars <> 2 ... (etc.) --

Android studio SDK Manager includes API Level 30, but do I need to download a different java JDK?

Thanks!

Panos Merakos

Hello JereMiami,

What is the version of your Android SDK Build-Tools? It has to be at least v30 - I suggest installing version 30.0.3 since it is tested extensively.

Open Android Studio -> Open SDK Manager -> go to tab SDK Tools -> Check "Show Package Details" at the bottom right and then you'll see version 30.0.3 of the Android SDK Build-Tools

Hope this helps.

mikey

for Mx macs, the J8 installer doesn't seem to place the JDK properly - or at least LC doesn't recognize it. The J11 installer does seem to be recognized by LC, though.

mikey

i also got the "service support class" message
the reason was
error: Source option 5 is no longer supported. Use 6 or later.
error: Target option 1.5 is no longer supported. Use 1.6 or later.

Panos Merakos

@Mike

I think the error you get is because LC is using J11. You probably have both J11 and J8 installed, and LC picks J11. What are the contents of this directory:

/Library/Java/JavaVirtualMachines/

Cheers,
Panos

mikey

is this maybe related to adk not using 8 any longer? that's what i was seeing when i searched for the error.
I installed adk from the link, above. that installs android studio 21.3.1.
Then I installed J8
When I went to LC Prefs -> Mobile Support, and chose adk, the JDK path is blank
If I install J11, LC recognizes the JDK.

Panos Merakos

@Mike

What are the contents of this directory: /Library/Java/JavaVirtualMachines/ ?

My guess is that you have 3 subfolders there:

- J11
-
- J8

And when no J11 is present, LC picks . When J11 is there, it is the first item, so LC picks that. But this is just a shot in the dark. In a correct setup, you should have only one subfolder: /Library/Java/JavaVirtualMachines/jdk1.8.0_333.jdk

mikey

i do only have one.
jdk1.8.0_341.jdk
that's the way i started.
but after pointing at android studio, lc couldn't find the jdk
so i started reading, and found a discussion that adk now uses j11 (even though LC says use J8), so i tried j11. lc was able to find that folder
then the error
then i uninstalled j11
and now lc can't find the jdk, again.

Panos Merakos

OK I see. I think I found the problem - you must delete /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/ and then choose the Android SDK root folder again - hopefully this time LC will find the correct JDK path.

LC auto fills the

mikey

confirmed that fixed the problem. thanks, panos.

Mark Wieder

Strict coupling of Android v8 is hard-coded into the IDE. The the deployIsValidJDK() function in revdeploylibraryandroid.livecodescript has code that looks for "jdk1.8" and throws an error if it's not found. So until that's fixed you need 1.8 installed. Also the pathToPlatformTools() function looks for "android-8". And kBundleToolVersion is 1.8.
Note: if you patch the deployIsValidSDK() function you can actually get informative error codes about what's going on.

Panos Merakos

Thanks for your comment, Mark. If I remember correctly, there were some other issues (rather than just updating the hard-coded values of "8" and "1.8") that prevented us from updating to newer JDK versions - it might be the case some tools in the jdk bundle that LC is using have been deprecated, or renamed, or replaced by others, or moved to a different location in newer versions of the JDK. So it requires some work to address these issues - that's why LC still requires JDK 8.

Cheers,
Panos

Philippe Coenen

Hi I think everything is installed. I can run the virtual devices on the emulator and ll that. But when I select a device and I hit the test button her is what I get:
-----------------------------------
Installation of app failed: adb: failed to install
C:/User s/animator/AppData/Local/Temp/tmp38.ap k:
Failure [I NSTALL_PARSE_FAILED _NO_ CERT IF ICATES:
Scanning Failed.: No signature found in package of
version 2 or newer for package
com.yourcompany2.yourapp]
Performing Streamed Install

Panos Merakos

Hello Philippe,

I think this error means that in the standalone application settings for android, you have chosen "Sign with my key" but you have not provided a .keystore file. Does it work if you change this option to "Sign for Development only"?

Kind regards,
Panos

Philippe Coenen

Hello Panos,

There is an option in the android standalone setup to sign with no keys.
I chose that and it was working.
Thanks for the tip, anyway.

JereMiami

Oliver Kalleinen

Hi, I need to have installed jdk17 for python development. How can I get livecode to point to jdk-1.8.jdk. Livecode automatically picks the highest jdk. Is there a specific reason for it, why wouldn't it be possible to set the path manually? I am on macos venture. Thanks

Panos Merakos

Hello Oliver,

You can navigate to the Preferences > Mobile Support window and issue this command from the msg box:

set the visible of button "chooseJDK" of card "MObile Support" of stack "revPreferencesGUI" to true

This will reveal a button that will allow you to choose the desired path, which in your case should be:

/Library/Java/JavaVirtualMachines/jdk1.8.jdk/Contents/Home

Hope this helps.

Kind regards,
Panos
--

Yashine

thank you for the above, address was different from library but it works,
now i was able to produce .exe file for some apps but no .apk file showing,
and one of the apps it is giving error still

could not compile service support class

yet there is no visible error in the app...

sam norris

Hello Yashine,

Could you provide us with a screenshot of your mobile standalone settings? We suspect it's an issue with the version of JDK used (too high rather than too low) but would like to see for ourselves if that is the case.

Robert Cailliau

I get
There was an error while saving the standalone application
could not link resources - error:
aapt2 W 01-25 15:34:08 44575 2187053 LoadedArsc.cpp:657] Unknown chunk type "200".
No idea what that might mean, but also in the SDK manager I can't click Android 13 (Tiramisu) 33, but I can click others.
I'm on LC 9.6.11 and Ventura.

Panos Merakos

Hello Robert,

Have you installed Android Studio? Or just the SDK tools? Could you also post a screenshot of what you see in the SDK Manager - where Android 13 is un-clickable for you?

Kind regards,
Panos
--

Robert Cailliau

Thanks for fast response Panos. Yes, Studio is there, and I had it all working a few months ago.
Don't know how to post screenshots here, but you can find them at
https://www.cailliau.org/Android/

Panos Merakos

Hello Robert,

Thank you for the screenshots.

Hmm, you do need to install Android 13 (API 33) from the SDK Platforms tab of the SDK Manager. I am not sure why it is not possible to click on it. What happens when you do so? Do you get an error or something? Can you click on other checkboxes, e.g. on Android 10? It might be worth restarting Android Studio.

Kind regards,
Panos

Robert Cailliau

Hi Panos:
Needless to say, I have restarted etc. When I click on 33, simply nothing at all happens. And yes, I can click the others and then they change state.
I'll reinstall Studio first & experiment, so more later.

Julian Moors

I'm having issues with LC being able to pick up Android Studio as well as the JDK. After following the instructions above I have installed Android Studio Iguana with Android SDK 13 ('Tirimasu') API Level 33 with the SDK Build Tools v35. I also installed JDK 1.8 from the Oracle website and now I'm trying to setup LC 9.6.11. LC isn't picking up the JDK and I can't get it to recognise the Android Studio folder.

Heather Laine

The Build Tools need to be v31 or 30, version 35 is not supported.

Trevix

Not able to install standalone on Android 13:
I am using LC10dp8, OSX14.4.1,JDK1.8,Build tools 31.0.0 (only this one).
I receive the following error when ADB testing:
"Unable to build app for testing: (BT:1.8.0) Error: Version code not found in manifest" etc....
What is the installer talking about?
Thanks (more info on the forum: https://forums.livecode.com/viewtopic.php?f=53&t=39127&p=230097#p230097)

sam norris

Hello,

A few questions to help us investigate:
Do you experience this issue with other stacks, even a simple one?
Are you using a custom manifest in the Copy Files?
Is there any chance you have edited revsaveasandroidstandalone.livecodescript in some way, even minorly?

Oliver Kalleinen

Still wanted to say thanks to Panos for the great answer from December 11, 2023 - see above. What a great trick, Livecode never stops to surprise. But here is my current question: Is there any rough expectation for when we can deploy to Android API level 34? Thanks.

Panos Merakos

Hello Oliver,

You're welcome :)

RE support for API 34 - Android 14, you can already **deploy** to a device running Android 14.

What is not supported yet, because it is not needed yet, is to **build** the standalone against the API 34 **SDK**.

At some point the Google Play Store will require all apps that are submitted to have been built against the API 34 SDK, but we will have added support for this until then :)

Kind regards,
Panos

JereMiami

Upgrading from 9.6.11 to 10.0. Currently, I have APIs 33/44 and Build Tool 31.0.0.

But with 10.0 I get he "cannot build class bundle." What is API and Build Tool version for LC 10.0?

Panos Merakos

Hello JereMiami,

I am wondering if this is because of the Java version - what is the JDK path that is auto-filled in the Mobile Preferences?

The API and Build Tools for LC 10.0 are the same (API 33/34 and Build Tools 31.0.0.

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.