Search code examples
androidjaradb

add external jar to an android project *manually* (without eclipse etc)


my problem is simple: in the web there are numerous ways and tutorials on how to include jars in an android application through eclipse, android studio etc. I want to do it manually; so, I want to know which files do I have to edit to bind my app with the specific jars.


Solution

  • in the web there are numerous ways and tutorials on how to include jars in an android application through eclipse, android studio

    That is because the use of third-party libraries is tied to the build system being used to build the app.

    I want to do it manually

    It is unclear what "manually" means in this context.

    If you mean that you are using Ant, just put the JAR(s) in your project's libs/ directory, and you are done. Note that this will work with Eclipse as well.

    If you mean that you are using Gradle, you will need something like this in your build.gradle file:

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
    }
    

    Or, if the JARs can be found in a Maven or Ivy repository, you can reference those as well, by defining the repository in the repositories block and then simply specifying the artifact in the compile directive:

    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile 'com.google.guava:guava:11.0.2'
    }