1. 程式人生 > >[Android] How to import library into android studio

[Android] How to import library into android studio

Project Structure

這裡寫圖片描述

config

  1. A this project will use the library
  2. B is SlidingMenu ‘s build.grade file
notice:

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 22
    }

hint: above config should be the same with the project build-tools version

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}
apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:13.0.0'
}

android {
    compileSdkVersion 22
    buildToolsVersion "22.0
.1" defaultConfig { minSdkVersion 7 targetSdkVersion 22 }
sourceSets { main { java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'
] assets.srcDirs = ['assets'] manifest.srcFile 'AndroidManifest.xml' }
} }

3 . C this project’s build.grade file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

4 . D is setting.grade file

include ':app'
include ':SlidingMenu-master:library'