How to import slidingmenu on Android Studio?

前端 未结 5 1803
醉酒成梦
醉酒成梦 2020-12-04 20:30

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 im

5条回答
  •  青春惊慌失措
    2020-12-04 20:51

    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.

提交回复
热议问题