androidactionbarsherlockandroid-studioslidingmenu

How to import slidingmenu on Android Studio?


I'm using Android Studio, and as you know, importing libraries used in current IDE like Eclipse is not easy with Android Studio. I'm trying to import the slidingmenu lib into my project but I don't know how to do it well. I've tried as they said in this link How to import slidingmenu on Intellij Idea? But I failed again. So I hope someone can answer me and show me how it works.


Solution

  • Just so everyone knows the file structure that I am referring to (which does work):

    File structure I will be referencing

    In your APP's build.gradle file make sure you have:

    dependencies {
        // Your other dependencies go here
        compile project(':libraries:SlidingMenu')
    }
    

    In your SLIDING MENU's build.gradle file make sure it has the following:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.7.+'
        }
    }
    
    apply plugin: 'android-library'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile 'com.android.support:support-v4:19.0.0'
    }
    
    android {
        compileSdkVersion 19
        buildToolsVersion "19.0.1"
    
        defaultConfig {
            minSdkVersion 7
            targetSdkVersion 16
        }
    
        sourceSets {
            main {
                java.srcDirs = ['src/main/java']
                res.srcDirs = ['src/main/res']
    
                manifest.srcFile 'src/main/AndroidManifest.xml'
            }
        }
    }
    

    Your PROJECT'S settings.gradle file should look like this:

    include ":libraries:SlidingMenu", ':App'
    

    In android studio press the Tools -> Android -> Sync Project with Gradle Files button, then rebuild your project. If all went well you should be able to import the com.jeremyfeinstein.slidingmenu.lib.SlidingMenu library into your app's source files.