dpcunningham / process-spinup-devenv-ionic4-ng-on-linux

Process: Spin Up a Development Environment for Ionic 4 (default Angular) Apps
0 stars 0 forks source link

install: Android Studio (and various Java-related dependencies) #14

Open dpcunningham opened 4 years ago

dpcunningham commented 4 years ago

The Android Studio site promises the fastest tools for building apps on every type of Android device.

Whoo Hoo!

Note that there are important prerequisites for the Android Studio install: Java and various JREs.

Per: JRE vs OpenJDK vs Oracle JDK

Before we go on seeing the process to install Java, let’s quickly understand the difference between JRE, OpenJDK and Oracle JDK.

  • JRE (Java Runtime Environment) is what you would need normally to run a Java-based application. This is all you need if you are not a programmer.
  • JDK (Java Development Kit) is what you need to if you have to do some do some programming or develop software related to Java.
  • OpenJDK is Open Source implementation of Java Development Kit while Oracle JDK is the official Oracle version of Java Development Kit. While OpenJDK is sufficient for most of the cases, some programs such Android Studio suggests using Oracle JDK to avoid UI/performance issue.

There seems to be two distinct paths here:

  1. Download their tarball, unpack it somewhere, run a shell script to set things up.
  2. Try installs via standard Linux Debian/Ubuntu methods -- examples below:

An article that distills the details of the points above is: Installing Using Unofficial PPA, which offers:

Install Java First

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

Install Android Studio

sudo add-apt-repository ppa:paolorotolo/android-studio
sudo apt-get update
sudo apt-get install android-studio

Remove Android Studio (if it ever comes to that)

sudo apt-get install ppa-purge
sudo apt-get remove android-studio
sudo ppa-purge ppa:paolorotolo/android-studio

Yeah....

All this is massively broken after April 2019 -- details are 'splained below, and in the following issues:

keppel2 commented 4 years ago

You shouldn't have to remove android studio unless you need disk space. One trick I remember is to always install the JDK, and the JRE will be chained in.

keppel2 commented 4 years ago

Professionally, I've deployed to devices for VR/Unity/Android, and Android Studio. The Mac made this pretty easy to do!

dpcunningham commented 4 years ago

Rework Android Studio into a Standard /opt/-based Installation

...or /var. I don't really care, as long as it's standard-ish. Ima chose /opt/

When I did my first install, I was expecting a Debian-style apt-get install cycle. I was disappointed to see I'd have to deal with an old-school tarball. Lowering my expectations, I then prepared for a .deb file that I could install. Imagine my crestfallen look, as I beheld a tarball that I would just have to splatter somewhere & hope for the best.

And, by the way, the installation instructions were pretty much... shite.

After doing a few more of these old-school installs required for Android builds:

We will bring the Android Studio installation into line with this approach as follows:


OK, here's where android.studio.sh ended up:

$ cat /etc/profile.d/android.studio.sh

# export ANDROID_HOME=/opt/android-studio       # This does NOT work.  The docs... suck.
                            # You don't point to where the package is installed.
                            # You point to where it initially laid down some dirs.
                            # Seriously?  What. The. Flock.

export ANDROID_HOME=/home/dpc/Android/Sdk       # This DOES work.
                            # Noted as deprecated in current build cycle

export ANDROID_SDK_ROOT=/home/dpc/Android/Sdk       # This is noted as the new standard in builds...

export PATH=$ANDROID_SDK_ROOT/platform-tools:$PATH
export PATH=$ANDROID_SDK_ROOT/tools:$PATH
export PATH=$ANDROID_SDK_ROOT/bin:$PATH

# export PATH=$ANDROID_HOME/bin:$PATH           # Redundant (since ANDROID_HOME = ANDROID_SDK_ROOT).
# export PATH=$ANDROID_HOME:$PATH

$ echo  $ANDROID_HOME 
/home/dpc/Android/Sdk
$ echo  $ANDROID_SDK_ROOT 
/home/dpc/Android/Sdk
$ echo $PATH
/home/dpc/.local/bin:/usr/lib/jvm/jdk1.8.0_231/bin:/opt/gradle/bin:/home/dpc/Android/Sdk/bin:/home/dpc/Android/Sdk/tools:/home/dpc/Android/Sdk/platform-tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Desktop Integration Issues/Approaches

Bypassing standard Ubuntu/Debian-style installation methods results in... piss-poor integration.

Let's see what other people recommend:

DDG: install android studio on linux mint

DDG: install android studio on linux mint 19


Configuring the SDK Manager:

This is important to avoid the build failures detailed in the issue comment: [Deal with missing Adroid Studio "Build Tools" (SDK Components?)](Deal with missing Adroid Studio "Build Tools" (SDK Components?))

Ridwan's Article: How to Install Android Studio on Linux Mint 19 notes the following very important step for Android Builds:

STEP 2: Configuring SDK Manager Launch Android Studio again if you have not already done so. Notice the 'Configure' on the last line of the screen – click on it and then click on the 'SDK Manager' item (see below). For your information, SDK stands for Software Development Kit.

If you don't you will likely need to deal with build problems outlined below: Deal with missing Adroid Studio "Build Tools" (SDK Components?)