5

I'm super overwhelmed with the tons of information out there and my issue is a pretty simple one.

I have made a project in IntelliJ Idea which has a package called com.example.util. In this package, I've got some static classes that I want to use in other projects.

Now, I have an Android Project and I want to use the classes in that util package.

However, I can't find an easy way that allows me to keep a flow state editing the two projects (Android and Util). I can compile the util package into a single JAR file and then copy-paste it inside the libs folder in Android but that's too much work and not efficient.

Can someone explain me this? All I want is to keep writing on the Util package and have the Android project pull all the classes.

Afonso Matos
  • 2,406
  • 1
  • 20
  • 30
  • Have any of these answers answered your question? If so, please consider accepting the most helpful answer. – Keara Dec 17 '17 at 23:01

3 Answers3

2

Maybe you can put the classes you want to use in a library: Create multiple projects in Android Studio

Here is a little snippet from an answer in the above post describing how to add your library to the project:

In settings.gradle of project add

include ':commonLibrary'
project(':commonLibrary').projectDir= new File('../path_to_your_library_module')

In build.gradle add 

compile project(':commonLibrary').
Keara
  • 589
  • 1
  • 6
  • 17
1

Go to File, Click New - Import Module Add the downloaded project After importing, right click on your project and select Open Module Settings In Modules section, select app, go to dependencies tab, press '+' and select Module dependency. Done!

https://stackoverflow.com/a/35223130/6060743

Or

https://github.com/MagicMicky/FreemiumLibrary/wiki/Import-the-library-in-Android-Studio (follow method-2 till step 7)

beginner
  • 528
  • 4
  • 16
0

It is very simple. On your gradle build within the "dependecies" block add the line:

compile project(":path:myproject")
HaroldSer
  • 2,025
  • 2
  • 12
  • 23