gradle

How to configure an Android project to use Java 8

As a quick note today, if you need to configure an Android project to use Java 8, I found that adding this setting to the app-level build.gradle file worked:

compileOptions {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

You can also use this syntax:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

That setting goes inside the android setting in the build.gradle file, as shown here:

Notes on how to build and run an Android application from the command line alvin March 6, 2019 - 8:21pm

As a brief note to self, this is how I compiled/built an Android application (APK) from the MacOS command line and then ran it in an emulator. I include both my application- and system-specific notes, as well as the more generic commands I found at this Android.com URL:

Some RxJava example source code (Hackers at Cambridge tutorials)

I recently watched the three Hackers at Cambridge Introduction to RxJava videos, and coded along with them. If you’re interested in some example RxJava code, here’s what I typed in.

The first thing you do is create a new Gradle/Java project with these commands:

mkdir MyProject
cd MyProject
gradle init --type java-application

With that project created you can begin creating some Java/RxJava code.

Android Studio - How to import a jar file (in a libs folder)

I just started using Android Studio 1.x and quickly ran into a problem where I needed to use a Jar file in my Android project. In short, this image shows the steps I followed to import the Jar file into my project. As an important note, I put the Jar file I needed in an app/libs folder, which I created in my project. As the image shows, this affects your Gradle build configuration. (I found this info at this SO link.)