How to create a Library project in Android Studio?

How to create a Library project in Android Studio?

Creating a library project in Android Studio was easy enough to do. Until Android Studio was updated to 3.1+.

Then my tasks failed: (which like everyone else I learned from Google'n)

task clearJar(type: Delete) {
delete 'build/libs/CustomFramework.jar'
}

task makeJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('build/libs/')
include('classes.jar')
rename ('classes.jar', 'CustomFramework.jar')
}

makeJar.dependsOn(clearJar, build)

The problem is that Android Studio no longer creates the following dir:

2018-05-24_15-24-11

Quick Fix: Modify the top-level gradle file and revert back to 2.1.2 versus having it at the latest...

Here is an example of that.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

You'll have to allow the project to adjust for the changes. I just accepted all of the default fixes that Android Studio recommended after I resync my project with the above change. Hope it works!