Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create STANDALONE Android Studio (1.5) library project

I need to create an Android Library and deliver the final .jar file to the clients.

I am new to Android development (three days). I've been developing iOS for the last 4 years. I went through Google's official documentation and tutorials to get a feel for the platform (I don't want it to be obvious that an iOS guy was writing the library).

I don't have any problems with Java, but I do with Android. I decided to go with Android Studio since it is the official IDE. I am using version 1.5.

PROBLEM:

So as I said, I need to create an Android Library and deliver the .jar file to the clients. I would like this Android Studio project to be a standalone library project with its own unit tests. I don't want to create an unnecessary App project, and then add an Android Library module to it. I want to create a separate App project which will include this .jar file, so I can test it in the way it will reach our clients.

I've seen a lot of options online for how to accomplish this, but all of them seem a bit "hacky" (e.g. rename this folder, change that app-project-setting and make it a library project). Is there no way to create a Library project from a new project wizard in Android Studio?

What are your suggestions on how I should proceed with this? Is there some elegant solution to this without these tricks to re-configure the App project?

EDIT

Here is what the new project wizard looks like: enter image description here

enter image description here

I select "Add no activity" here enter image description here

like image 569
vale4674 Avatar asked Nov 27 '15 16:11

vale4674


People also ask

What is .AAR file in Android Studio?

An AAR file contains a software library used for developing Android apps. It is structurally similar to an . APK file (Android Package), but it allows a developer to store a reusable component that can be used across multiple different apps.


1 Answers

This may not feel comfortable for a person from other platform/IDE/world, but this is The Way. Personally i'm getting annoyed with Xcode every time i use it in the exact same way you're annoyed with AndroidStudio now. But lets get down to business:

  1. Create an empty project and select "Create no activity". enter image description here
  2. When everything is set, go to "File\New\New Module" and select "Android Library" enter image description here
  3. Give a name for created library and click "Finish".
  4. (Optional) go to "Run\Edit Configurations" and set everything like below: enter image description here

  5. Now open the librarie's 'build.gradle' file. Make sure to open the file from exact same folder which is named with your library name, because there are a couple of 'build.gradle' files all over the place. Remove support-library entry from the file: enter image description here

  6. Write some code and when you're ready to deploy the library set everything like this: enter image description here

Go to "Build" menu at the top and select "Build APK".

And about unit tests: enter image description here

**Edit 1: **

If you really want to remove the 'app' folder, than follow instructions on a picture below: enter image description here

like image 99
mykolaj Avatar answered Sep 28 '22 00:09

mykolaj