Leave part of the APP in library

Asked

Viewed 304 times

2

I have an APP with a separate package(Package) for PUSH notification, I would like to take this package and turn it into Library, so that in future apps only add to Library in my project.

How can I do that?

EDIT

IDE: Eclipse

  • Android Studio, Eclipse or other? Try edit and better detail your question, so you can get better answers.

  • Sorry, I’m using Eclipse

4 answers

1


With Eclipse you can create a JAR file containing the classes and project information. Unlike files .jar, AAR files, possibly created using Android Studio, can contain Android features and a manifest file, which allows you to package shared resources such as layouts and drawables, in addition to Java classes and methods.

To create a lib You will follow the same flow to create a new project, but a flag with the following message:

Mark this project as a lib.

See in the image:

inserir a descrição da imagem aqui

Soon after just import into your main project as a library. For access, right-click the mouse in the project and go on proprieties > Android. See in the image below:

inserir a descrição da imagem aqui

See also how create a library using Android Studio

  • Perfect! I’ve already started doing it here. Take away one more question I need to pass the value of a variable that is in the app to my Library. How can I do it in the best way?

  • @William did not understand. You want to send a value to the library, so that it returns you something?

  • @William if that is the case, for example you can create a method calculatRaio(String cicunferencia) that returns a double. Then you will import the library and call the method calculatRaio(Circ) passing the circumference as parameter. This is a traditional way of doing. ^^

  • OK I’ll make a method, I didn’t know that you could call a method of the app inside the Library. I have a string that in the app I need the library to have access.

1

I do this: (assuming you know how to use github

  1. In android studio, go to file build.Gradle(Module: app) and upstairs, change your apply plugin: 'com.android.application' for apply plugin: 'com.android.library'
  2. Import the project into github inside the android studio itself. Go to VCS>Import into version control > Share project on github (obviously here Voce will have to have an account on github and the github Desktop installed on the pc)
  3. Go on https://jitpack.io/ and in the field Git Repo URL paste the link from your repository that was created on github and then gives a Look up.
  4. Then just follow the steps (they are very simple) in the images that appear just below in the jitpack site (which is basically just add a lib in your normal project).
  5. Ready!!
  • Thank you Mr_anderson, would you tell me how I do it using Eclipse?

0

0

It’s pretty quiet to do that..

First you’ll need to open the build.gradle of the module you want to behave like a library, and then change apply plugin: com.android.application for apply plugin: com.android.library

Now it will create an . AAR instead of an . APK.

To add a statement is also quiet, I advise you to take a look here: https://developer.android.com/studio/projects/android-library.html

  • I am not experienced in Android yet, so for the sake of knowledge, I would like to know what the advantages of doing this procedure?

  • Thank you Max Fratane, would you tell me how I do it using Eclipse?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.