• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Using external library (no .jar, folder with .java instead) in Android Studio

Guerlando OCS

Lurker
Apr 22, 2016
1
0
Hello, I just started a default project in Android Studio, compiled, and it worked fine. Now, I downloaded a library, that is, in fact, a folder with 3 .java files: one Main.java for testing and 2 Classes for usage on my app. I want to know two things:

How do I compile these files to use in my project? I simply put the folder inside app, so this is my structure:

src/main/java/com.example.myname.myapp/MainActivity.java
src/MyClassFolder/Main.java
src/MyClassFolder/Class1.java
src/MyClassFolder/Class2.java
src/MyClassFolder/AnotherLibrary.jar


So, what I wanted to do is this: I want to compile these files as they are in this folder, without having to move them to MyclassFolder/src/main/java.

I've found these instructions at the internet:


At /app/settings.gradle, i nclude this line:

include ':MyClassFolder'

edit /app/build.gradle and add, in dependencies, the line:
compile project(':MyClassFolder')


I did it, but this happens:


I seached and I think that it's asking for a default build.gradle file inside MyClassFolder. How may I create this folder? How can I tell gradle to compile these files in this folder, and how do I insert parameters to javac?
Also, what is /app/build.gradle for?


I also tried to move files to /src/main/java to see if it would work but it didn't also. I'm very confused :c
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones