Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to make a project depend on another

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.

like image 362
Afonso Matos Avatar asked Oct 18 '22 08:10

Afonso Matos


2 Answers

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').
like image 177
Keara Avatar answered Oct 23 '22 04:10

Keara


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)

like image 1
beginner Avatar answered Oct 23 '22 04:10

beginner