Adding a jar to Android Studio

Should be pretty simple right?
Well, the UI doesn't support it right now but it is pretty simple to handle manually, so you'll have to open your build.gradle file that should be in:
/projectName/

And add the following:
dependencies {
    compile files('libs/jarFileName.jar')
}


Example:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/MixpanelAPI.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 16
    }
}

Post a Comment