其他分享
首页 > 其他分享> > android – SlidingMenu集成的问题

android – SlidingMenu集成的问题

作者:互联网

我一直在尝试按照此问题中提供的指南在我的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')
}

标签:android,android-studio,slidingmenu
来源: https://codeday.me/bug/20190829/1764016.html