How do I configure Java for Cordova and Gradle on Ubuntu?

When I install Gradle on Ubuntu, it installs JDK11 but then Cordova complains. So I replace JDK11 with JDK8 and Gradle doesn't work. This includes changing the JAVA_HOME environmental variable. I would have thought that sudo npm install -g cordova should have taken care of all of this. IMO this should have been as simple as a short command with a package manager, but instead I find myself in dependency hell.

Currently, when I run cordova run android in the path of my project, I get the following:

Android Studio project detected
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.+' to <path stuff>
cordova-android-support-gradle-release: Wrote custom version '27.+' to <path stuff>
Failed to run "javac -version", make sure that you have a JDK installed.
You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.
Your JAVA_HOME is invalid: /usr/lib/jvm/java-11-openjdk-amd64

How exactly do I install Cordova with all dependencies and versions on Ubuntu? I'm looking for a complete and step-by-step set of instructions.

See also questions close to this topic

Whenever I run my app directly from the Android Studio, sign in fails to work but when I generate a signed apk and then run that apk on my phone, it works, but the whole process of generating an apk and then transferring it to my phone and then installing is very dull, so is it possible to test sign in system directly on an unsigned build of my app ?

I want to make a fitur to login, I want to make a feature to log in, initially I saw the response code shows 200, but when I saw the response body was null. I can still log in, but the logged in user data isn't saved. I used 2 db MySql and SQLite and im using retrofit and shared preference. And here my code

I'm having a problem with this library:
com.android.support:design:25.0.1

When I go to implement it using: implementation 'com.android.support:design:25.0.1' an error appears

or:Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward.

the strange thing is that when I go to syncronize and when I try to put in the xml: <android.support.design.widget.FloatingActionButton /> the piece of code turns red and if I go over it with the mouse it appears:

I create an app in which I have to send mail from any of the mail clients available. Now I have to perform some tasks when the user comes back to my application from mail client. But I have no idea how to track the user when he came back from the mail client.

I also want to that- it is possible to track that does user send mail or not when he came back to my application.

I am using phonegap-plugin-push on Cordova and some app users get push notifications every ~30 seconds. The problem is when their device is OFFLINE and they go online say 1 hour later, they are suddenly flooded with 120 push messages at once, crashing and freezing the app.

I have a webapp using Faye for push notifications. I've packaged that web app inside a cordova android app and runs fine, and I'm using Faye.js client to listen for notifications.

The problem is that, when the application is not running in the background, notificatons are not being listened.

I've used intents in the past (a very long time ago) for an Android native app to listen for notifications but I don't know which is the "Cordova" way to do this. I would also like this to be compatible with iOS.