My Guide to Mobile Applications (Android) on Ubuntu (Linux)

BEFORE! you install Wappler it is advised to install the following in order.

Lets install some tools we’ll need to get things done, and carry out one or two other things prior to getting things ready.

Update System:

Open a terminal session.

sudo apt update
sudo apt upgrade
sudo apt-get install build-essential

Install Curl:

Open a terminal session.

sudo apt install -y curl

Install GIT:

Open a terminal session.

sudo apt install git -y

Install Homebrew:

Open a terminal session.

Grab the script;

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add Homebrew to your path:

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

Check Brew is installed correctly:

brew doctor

Install JAVA RE:

Open a terminal session.

sudo sudo apt install openjdk-8-jre

Install JAVA JDK:

Open a terminal session.

sudo apt install openjdk-8-jdk

Set JAVA Home Path:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Add JAVA Bin to Path:

export PATH=$PATH:$JAVA_HOME/bin

Test JAVA:

java -version

You should see your new JAVA paths displayed.


Install Node JS:

Open a terminal session.

curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt install -y nodejs

Now check that Node is installed by running the following in the terminal:

node –version

Update System once more:

Open a terminal session.

sudo apt update

Install Gradle:

We are going to install Gradle 6.5.1 as the most recent version (7.3) is not recognised for some reason?

Open a terminal session.

VERSION=6.5.1
wget https://services.gradle.org/distributions/gradle-${VERSION}-bin.zip
-P /tmp
sudo unzip -d /opt/gradle /tmp/gradle-${VERSION}-bin.zip
sudo ln -s /opt/gradle/gradle-${VERSION} /opt/gradle/latest

Set-up environmental variables (open up your text editor):

sudo nano /etc/profile.d/gradle.sh

And paste in the following to the bottom of the file and save:

export GRADLE_HOME=/opt/gradle/latest 
export PATH=${GRADLE_HOME}/bin:${PATH}

Remember to save the file (CNTRL and O, then press Enter).

Make the script executable:

sudo chmod +x /etc/profile.d/gradle.sh

Load the variables in to the current Terminal Session:

source /etc/profile.d/gradle.sh

And verify the Gradle installation:

gradle -v

Install Android Studio/SDK:

Download Android Studio for Linux from the official Android Studio website (there are several other ways of doing this, including via the repository using the terminal, your choice).

Open Downloads directory.

Unzip the download.

Open the newly created directory and copy the android-studio directory in to your Home directory.

Browse to the bin directory within the android-studio directory and right click, open in terminal.

In the terminal enter:

./studio.sh

Follow the on-screen instructions to install Android Studio.

Install the SDK Build tools and SDK.


Create a desktop shortcut for Android Studio if one is not available:

Please see this link for instructions on how to do this:


Install Cordova:

Open a terminal session.

sudo npm install -g cordova

Install Wappler:

YAY! The moment has come to install Wappler.

Download Wappler for Linux and install.

Run the System Check.

If everything went well you should see no issues, everything should report back correctly:


Checking NodeJS installation and version…

v17.1.0

NodeJS is correctly installed.

Checking Cordova installation and version…

10.0.0 (cordova-lib@10.1.0)

Cordova is correctly installed.

Checking for Android Studio installation…

Android Studio is correctly installed.

Checking Java SE JDK installation and version…

javac 1.8.0_292

Java SE JDK is correctly installed.

Checking Gradle installation and version…

Gradle 4.4.1

Build time: 2012-12-21 00:00:00 UTC

Revision: none

Groovy: 2.4.17

Ant: Apache Ant™ version 1.10.7 compiled on October 24 2019

JVM: 1.8.0_292 (Private Build 25.292-b10)

OS: Linux 5.11.0-40-generic amd64

Gradle is correctly installed.

Checking for Android SDK …

Android SDK is correctly installed.

System check successful!


If you are experiencing some build errors please make sure to check the Cordova Platform Guide for android:

http://cordova.apache.org/docs/en/latest/guide_platforms_android_index.md.html

You may get an error with regards to the following (building your Project in Wappler, Android Studio is fine):


Building your Cordova Project for android …

Checking Java JDK and Android SDK versions

ANDROID_SDK_ROOT=undefined\Android\sdk (recommended setting)

ANDROID_HOME=undefined\Android\sdk (DEPRECATED)

‘ANDROID_SDK_ROOT’ environment variable is set to non-existent path: undefined\Android\sdk

Try update it manually to point to valid SDK directory.

Error building your Cordova Project for android!


So let us try and set those paths manually…

Open a terminal session.

export ANDROID_HOME=$HOME/Android/Sdk

export PATH=$PATH:$ANDROID_HOME/tools

export PATH=$PATH:$ANDROID_HOME/platform-tools

Restart your system so these changes take effect.


Issues/Warnings/Notes:

Android Studio may overwrite some of the configurations made using this guide, it may downgrade Gradle for instance.

If you are required to do this go back to the Gradle installation guide above.

Wappler may still display the error building your Project.

I believe this is a BUG and hopefully it will be resolved in the next update (this guide was written using 4.4.1).

If prompted to update your Project in Android-studio DO NOT DO IT, it will break your Project (only update Gradle if prompted, DO NOT update anything else in Android Studio), YOU HAVE BEEN WARNED (if you do, please BACKUP your Project Directory first!).

3 Likes

Right, new version of Wappler (4.4.2) and an update for the guide. The Team have done an amazing job with the most recent version and now allow you to set your own paths to the Android SDK, JAVA RE/SDK and Gradle! Simply superb! If you followed this guide you should have something similar to the below image (REMEMBER to restart Wappler after making these changes, Experimental Features must be enabled, and you will find the dialogue to set these variables in your Settings area under Mobile).


VERY VERY VERY IMPORTANT!!

There is an issue with the latest SDK Build Tools within Android Studio! NOTHING TO DO WITH WAPPLER!

Versions 31.x.x and 32.x.x will be reported as corrupted, and you will be asked to reinstall them, only to get the same error or the following error:

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

How to rectify:

  • Open Android Studio.
  • Goto Tools SDK Manager.
  • Select SDK Tools.
  • Remove Build Tools all together (at least any above 30.0.3 anyway).
  • Click Show Package Details.
  • Tick on 30.0.3.

  • Click OK and Apply.
  • Build Tools 30.0.3 will be installed.
  • Close Android Studio.
  • Restart Wappler.
  • Click the Build button in Wappler.

Your Android Application will now build successfully with no errors! The output directory will be displayed.

As a side note all that I did to set up this Project was:

  • Open Wappler.
  • Create a New Mobile Project.
  • Selected Bootstrap.
  • Added the Android Platform.
  • Then hit the Build button.

Nothing more complicated than that folks!

Some idiosyncrasies:
You may need to set yourself as root to build, depends on your set-up as no request for sudo login is displayed. Meaning you may need to change the permissions on the platforms/android directory to allow you to write to the directory, this is only a maybe, so if you have issues that could be why…

Again I must give praise to @George @Teodor and @patrick for the rapid adoption of allowing the user to set the paths for the Android SDK, JAVA RE/SDK, and Gradle paths, it made a huge difference!

Now go get building those Android Applications in Wappler, in Ubuntu! You have no excuses!

Good luck. Am here to answer any questions via PM or tag me in your Topic.

:smiley:

5 Likes