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.
-
Create a project.
-
open file in the left project menu.(app/build.gradle): Gradle Scripts > build.gradle(Module: XXX)
-
change one line:
apply plugin: 'com.android.application'
->'apply plugin: com.android.library'
-
remove applicationId in the file:
applicationId "com.mycompany.testproject"
-
build project: Build > Rebuild Project
-
then you can get aar file: app > build > outputs > aar folder
-
change
aar
file extension name intozip
-
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.