1. Download our Official Android App: Forums for Android!

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

Discussion in 'Android Development' started by Guerlando OCS, Apr 22, 2016.

  1. Guerlando OCS

    Guerlando OCS Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    1
    Joined:
    Apr 22, 2016

    Apr 22, 2016
    1
    0
    15
    Male
    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
     

    Advertisement

  2. Unforgiven

    Unforgiven OK Google
    Moderator
    Rank:
     #1
    Points:
    4,238
    Posts:
    36,320
    Joined:
    Jun 23, 2010

    Jun 23, 2010
    36,320
    42,457
    4,238
    Male
    Douglas, MA
    Application Development thread moved to the Development forum for better exposure.:)
     

Share This Page

Loading...