Page 1 of 1

Android Studio - Additional JDK not needed (Solution to Java is none error)

Posted: Sat Oct 24, 2020 2:51 pm
by Bernard
Like many people on this forum in recent years, I got the "Java: none" error after installing Java 1.8 and then installing Android Studio (as per instructions from Livecode here: ... oid-studio). Many people have been confused by these instructions in recent years (for example: viewtopic.php?t=26477 and here: I was staggered to see that for years users have been struggling with setting up for Android and since following the Lesson and reading various possible solutions in Forum posts but nothing worked for me, I decided to get to the bottom of the problem so that others don't have to go through this frustrating experience. I must have spent more than 8 hours trying to figure this out (on both Windows and OS X), involving multiple installs of JDK/Android Studio on both.

a) The Livecode lesson is wrong (since 2016 Android Studio does not need a separate JDK install),
b) how LC preferences pane looks up the relevant JDK is way too complex (the IDE needs to just set the path based on the Android Studio (AS) install (which is different to the AS SDK path).

SDK path (Windows) in the LC Prefs windows looks like this:

Below it the JDK path needs to look like this:
JDK Path: D:/Programs/Android/Android Studio/jre

I'm not really surprised by this confusion, as there were plenty of other misleading trails when the fix is really simple.

Android Studio version is 4+ (the downloaded file has 201 in the crazy numbering).
as204dl.PNG (4.13 KiB) Viewed 813 times
If one looks inside some of the .bat files once AS is installed, these batch files branch depending on if Windows is version "NT" or not - if not, it's assumed to be Win95/WinME! Mind-boggling to think that at the cutting edge of Android development (1gb of RAM for AS/emulator to run) they are providing for Win95 users.

However, in investigating what AS installs I found that version 2.2+ comes with its own OpenJDK - see (since June 2016 Google's install instructions for Android Studio dropped any reference to installing a JDK). What AS install does not do is set the variables/registry keys LC expects when looking for an appropriate JDK (so the JDK bundled inside AS is not found by the LC IDE).

Here's what the studio-config.html says:

"A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects". From < ... o/42172066> I found plenty of other instructions (external to Livecode) referring to parts of Android Studio which were wrong (either the referenced feature has been moved or renamed).

After installing Android Studio (v4.1 i.e. file named ide-201.xx version as in screenshot) I checked Android Studio worked and that an x86 emulator could be created. Once assured that was working, I knew that AS was finding and using a JDK even when LC could not. I needed to find out why LC was failing to find the needed JDK. I enabled the (hidden) "ChooseJDK" button on the LC prefs pane to inspect what LC was looking for in setting the JDK version. Depending on the platform, LC relies on the OS being able to provide a pointer to the right JDK. In my experience this failed on both MacOS and Windows.

With the relevant section of the Preferences window open, I put this in MessageBox

Code: Select all

set the visible of button "ChooseJDK" of group "Android SDK" of card "Mobile Support" of stack "revPreferencesGUI" to true
This button is normally only visible if platform() is "linux". This button enables one to choose the JDK within the Android Studio installation (the folder containing e.g. java.exe and javac.exe). So for me it is this:

JDK Path: D:/Programs/Android/Android Studio/jre

Meanwhile the line above JDK Path (pointing to SDK root) will say something like:


After ensuring that the two Android relevant fields pointed to the SDK home and the (Android bundled) JDK, I created a test stack, saved it and set the standalone settings, then chose the Android emulator listed in the menu "Development/Test Target) and tested my basic stack on the emulator. Bingo.

So, here's what LC needs to do:
a) edit the lesson to remove any reference to JDK
b) change how the Prefs pane looks for a JDK e.g. let the user point to the root directory of the Android Studio binaries and build up a path to Android's included JRE directory.

Update: forgot to mention that one needs to set the PATH environment variable so that it points to the relevant (home) directory for the sdk java tools. LC in launching those tools could include the full path to that home. For anyone trying to do what I've done, once the path variable is set then opening a new terminal one should be able to call
java -version
javac -version
and the OS should find those executables and launch them. My guess is that within the LC IDE is that these programs are called without a full path to them, hence the need to set the path.

On OS X the "home" folder is within the "Android" and the path should point to that folder (javac is within a folder within home/).

Re: Android Studio - Additional JDK not needed (Solution to Java is none error)

Posted: Mon Oct 26, 2020 8:39 pm
by sphere
This may be partly true.
As some people prefer not to install Android Studio but only the Command Line version. Although with the latest versions it is a bit more work to download SDK's and related stuff as it then all goes via command line. Also one could choose to use OpenJdk or Oracle's.
I don't know if a Java is also installed with the command line. If not, one still needs to install it separate.

Anyway thanks. I'm using Studio too, also because i'm a bit focusing on Flutter now. And probably can remove Oracles Java JDK now.

Re: Android Studio - Additional JDK not needed (Solution to Java is none error)

Posted: Tue Oct 27, 2020 12:41 am
by Bernard
Once I'd got it all installed and working, I started to strip out as much of the Android IDE as I could (in fact, I'm testing on physical devices). However, when searching for what to do with Android (I've not done anything with it for some years, and didn't any longer have a machine with Android tools and Livecode on it), the Lesson on Android Studio was the one that search engines returned as the most relevant. So I assumed that was what one now had to use. But seeing lots of people going round in circles (as indeed was I), I wanted to find the simplest, most standard Android way of doing things. Having got that working, and getting LC to work with that on Win/Mac I then wanted to strip down the Android tools to the least needed. In doing that, I realised that I could probably just install command line tools. But having done all this work (and not assuming everyone will want to have a minimal install like me) I thought I'd write it up so that LC could offer a single, simple Lesson on how to get a standard install working. That could then link to a more advanced, stripped-down install.

Even with iOS it's possible to just launch emulators from the command line without running XCode, but I guess the people who are using iOS know that.

Re: Android Studio - Additional JDK not needed (Solution to Java is none error)

Posted: Tue Oct 27, 2020 7:06 pm
by sphere
Thanks Bernard, people will appreciate it.
Even with iOS it's possible to just launch emulators from the command line without running XCode
Yes true