SlidingMenu 集成的问题

Problems with SlidingMenu integration

我一直在尝试按照这个问题中提供的指南在我的 Android Studio 项目中使用 SlidingMenu 库:

How to import slidingmenu on Android Studio?

我已经能够获得所描述的文件结构并同步和构建项目而没有错误。然而,当尝试将滑动菜单导入我的应用程序源文件时,我遇到了符号解析错误。

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu; // Error message: Cannot resolve symbol 'SlidingMenu'
import com.jeremyfeinstein.slidingmenu.lib.BuildConfig;

第二个导入是 Android Studio 建议的唯一导入,但我什至在遵循给定路径时在我的项目中找不到 BuildConfig 文件。

我需要更改什么才能将 com.jeremyfeinstein.slidingmenu.lib 中的所有 类 导入我自己的 类?

我的应用 gradle 文件如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.me.appname"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:7.0.0'
    compile project(':libraries:SlidingMenu')
}

SlidingMenu gradle 文件:

buildscript {
    // define the repo which is to use
    repositories {
        mavenCentral()
    }
    // define the classpath for Gradle Android Plugin
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.+'
    }
}

// declaring that the project is a library
apply plugin: 'android-library'

// declaring all dependencies the project needs
dependencies {
    compile 'com.android.support:support-v4:19.0.0'
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        // this values you can read out from the Manifest (but I add the right values for you)
        minSdkVersion 17
        targetSdkVersion 21
    }

    // because Android Studio has a different file structure than Eclipse
    // you have to say Android Studio where the files are located
    sourceSets{
        main{
            java.srcDirs = ['src/main/java']
            res.srcDirs = ['src/main/res']

            manifest.srcFile 'AndroidManifest.xml'
        }
    }
}

项目设置gradle:

include ":libraries:SlidingMenu", ':app'

获取 AAR port of the library (v1.3)。

GitHub 页面已关闭,因此您必须手动导入 that AAR

顶部 build.gradle 文件:

repositories {
    flatDir {
        dirs 'libs'
    }
}

将 AAR 文件放在模块的 libs 文件夹中,然后在模块 build.gradle 文件中:

dependencies {
    compile(name:'library-1.3', ext:'aar')
}