Android JAVA_HOME from Wappler editor

On a mobile project I have android platform added and working all the way through the play store, except I cannot build from within Wappler (builds from android studio work.)

Error received on build:

Building your Cordova Project for android ...
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/Users/pauka/Library/Android/sdk (recommended setting)
ANDROID_HOME=/Users/pauka/Library/Android/sdk (DEPRECATED)
Using Android SDK: /Users/pauka/Library/Android/sdk
Subproject Path: CordovaLib
Subproject Path: app

ERROR: JAVA_HOME is set to an invalid directory: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

But if I go into terminal in wappler, env shows this for JAVA_HOME, which is a valid directory.

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home

so where do I go to get JAVA_HOME fixed for Wappler?

hi Ken,
I think I got similar problem…
am investigating how to fix it

Maybe this will help you gentleman? From a working compiling Mobile Project, check.reqs.js is the file (contained within \platforms\android\cordova\lib):

Thanks Dave…took a look around, and I’m still stuck on this.

The end goal here is to get cordova android api level 30+ working as it is now required (rejects builds if not set).

I’ve tried upgrading gradle to 7.2 but get errors.

I’ve tried specifying version 10.1.1 (and also 10.0.1) of cordova platform when adding.

The one constant is the JAVA_HOME error that pops in wappler when doing a system check of Gradle. Because of that error, it tries to install gradle, which then reports is already installed.

$JAVA_HOME reports a valid directory:

bash: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home: is a directory

but the gradle check attempts an invalid directory:

ERROR: JAVA_HOME is set to an invalid directory: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

While I haven’t figured out the JAVA_HOME issue, I think I’m making progress getting API 30 operational.

Here’s what seems to work:

Use Cordova plugin 10.0.1 – this is done manually in the terminal rather than adding via Wappler UI:

cordova platform rm android
cordova platform add android@10.0.1

Add to config.xml within the android platform section:

  <preference name="AndroidInsecureFileModeEnabled" value="true" />
  <preference name="android-targetSdkVersion" value="30"/>  

From what I’ve read, this reverts to the previous method of file mode access. It’s a little concerning that this is flagged as Insecure, but from what I’ve read, it is fine. Use at your own discretion. :slight_smile:

The sdk version entry just ensure the api target.

Over in Android Studio, you should be prompted to update from gradle 4 to 7 – go ahead and do this.

Now, back to the JAVA_HOME issue…

The error seems to occur after the build takes place, so I use the wappler build function, and then hop over to Studio in order to run in the emulator or physical device.

Something tells me this story will evolve. :laughing:

@George Anything you can do here to shed light on these two situations? JAVA_HOME error and needed to revert to FileMode for Android?

@Dave Thanks for the tip, but that file doesn’t exist in my project.
@mebeingken
I followed your instruction to remove and install Android10.0.1

In Android Sudio I got sdk not found errors every time.

After a few attempts and reinstalling the sdk’s I did the following to the gradle.properties file;

sdk.dir=YOUR SDK LOCATION

Then go to file-> sync project with gradle files.
After that I got the notification to upgrade gradle and upgraded to the latest.

Now in Android Studio I have my app running in the emulator via Android Studio
Oh and the login is working yay :grinning:

In the gradle build tools I set the jdk to the embedded version 11. Don’t know if that helps:

In Wappler use the Java SDK to that is installed with Android Studio.
That is why we point the JAVA_HOME to it, during the execution of commands in Wappler.

Don’t you have the JDK installed in the location under Android Studio? Is the path wrong?
Usually it is this path under Android Studio - unless they changed it…

We always use the one under Android Studio to be sure it is always the right JDK as the user may have many other JDK’s installed on the system.

Working set-up on Windows 10:

Android Studio:
File / Project Structure / SDK Location

Perhaps this is the cause – JDK location is now in Gradle Settings:

Are you running the latest release of Android Studio @mebeingken, think its called Bumblebee? I’m very reluctant to update as previous updates have caused numerous headaches. I’m looking at a system switch to Linux on one laptop and a fresh install of Windows 10 on a work laptop so will update everything from the bottom up so may well encounter your issues… So interested to hear if you resolve it?

Just fired up an older Mobile Project that previously compiled/built fine but under Wappler 4.2.2 hangs so will have to post a Bug Report on that one. Updating Cordova in the Project breaks it entirely so not sure if Wappler is backward compatible with older Cordova Projects? @George Maybe I should leave the questions until I get around to the Bug Report…

Have also found that without first removing the Android Platform from the Project and then adding it again any manual build commands such as cordova build anroid --release entered in the terminal fail… Again should probably make a Bug Report on that too… Going through some older Projects to test bits and pieces and hitting a few issues, so sort of gone off on a tangent in this thread so forgive me!

:wink:

Mac os

It seems to clear to me that on a MAC, the location of the jdk is now pulled from gradle, so @George can obviously fix that JAVA_HOME issue. But, what do I know. :rofl:

Here’s what is working for me:

Cordova Packages:

    cli: 10.0.0
        common: 4.0.2
        create: 3.0.0
        lib: 10.1.0
            common: 4.0.2
            fetch: 3.0.1
            serve: 4.0.0

Project Installed Platforms:

    android: 10.0.1
    ios: 6.2.0

iOS was really easy now that Cordova is directly using wkwebview.

I could not get Android to work without reverting back to file: method of access:

<preference name="AndroidInsecureFileModeEnabled" value="true" />

Hoping @George will comment on that as well.

3 Likes

Seems there is quite a difference between building on Windows and Mac, and their respective tool-sets, configurations etc. Must be a real headache for the team! Thanks for responding Ken, appreciated greatly sir.

@George Is this an easy fix for a upcoming release?

I hope so, what is the jdk bin path in your Android Studio app? You can open it in Finder and then right click “show contents” to go inside

I show that in a post above, no?

No I mean the exact path to the JDK inside the Android Studio app under your Applications.

That is the JRE (Java runtime) I need the JDK, something with the jdk in the path

Just making sure you saw this post showing that jdk is now used from Gradle.

Are you expecting in one of these folders? I’m not finding it.