Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Android Library Project Only

As much as I have researched, it seems that I am only able to create an Android Library within an Android Project. Is there any way in which I can create a Standalone Android Library and not have it within or alongside an App?

My scenario is to work on this Android Library and for it to create an AAR when I compile which I can then reference in a separate Android Project.

I so far have a project running but it has an App and a Library at the same level. I achieved this by creating a new project and then:

File -> New -> New Module -> Android Library.

like image 454
Subby Avatar asked Nov 08 '22 11:11

Subby


1 Answers

  1. Create a new Android Library, we'll call it "MyAar" (File -> New -> New Module -> Android Library)

  2. Now there should be a folder named "MyAar" on the Android hierarchy (usually the left most window in Android Studio)

  3. Add all the source code you want in there under the "Java" folder, and adjust your build.gradle file accordingly (the one that says "Modele:MyAar" and begins with apply plugin: 'com.android.library').

  4. Highlight "MyAar" on the Android hierarchy window, then press Build -> Make Module 'MyAar' at the bar on the top (where File, Edit, View... is located)

  5. Go to the folder YOUR_ANDROID_APPLICATION/MyAar/build/outputs/aar, you will see a MyAar-debug.aar. That is your .aar which you can now drop into any other project.

like image 70
Bill Avatar answered Nov 15 '22 06:11

Bill