How to create a library project in Android Studio and an application project that uses the library project

I wonder why there is no example of stand alone jar project.

In eclipse, we just check “Is Library” box in project setting dialog.
In Android studio, I followed this steps and got a jar file.

  1. Create a project.

  2. open file in the left project menu.(app/build.gradle): Gradle Scripts > build.gradle(Module: XXX)

  3. change one line: apply plugin: 'com.android.application' -> 'apply plugin: com.android.library'

  4. remove applicationId in the file: applicationId "com.mycompany.testproject"

  5. build project: Build > Rebuild Project

  6. then you can get aar file: app > build > outputs > aar folder

  7. change aar file extension name into zip

  8. unzip, and you can see classes.jar in the folder.
    rename and use it!

Anyway, I don’t know why google makes jar creation so troublesome in android studio.

Leave a Comment