Per*_*tor 3 android slidingmenu android-studio
我一直在尝试按照此问题中提供的指南在我的Android Studio项目中使用SlidingMenu库:
如何在Android Studio上导入slidemenu?
我已经能够获得所描述的文件结构并同步和构建项目而不会出错.然而,当我尝试将滑动菜单导入我的应用程序源文件时,我得到一个符号解决错误.
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu; // Error message: Cannot resolve symbol 'SlidingMenu'
import com.jeremyfeinstein.slidingmenu.lib.BuildConfig;
Run Code Online (Sandbox Code Playgroud)
第二个导入是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')
}
Run Code Online (Sandbox Code Playgroud)
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'
}
}
}
Run Code Online (Sandbox Code Playgroud)
项目设置gradle:
include ":libraries:SlidingMenu", ':app'
Run Code Online (Sandbox Code Playgroud)
GitHub页面已关闭,因此您必须手动导入该AAR:
顶级build.gradle文件:
repositories {
flatDir {
dirs 'libs'
}
}
Run Code Online (Sandbox Code Playgroud)
将AAR文件放在模块的libs文件夹中,然后放在模块build.gradle文件中:
dependencies {
compile(name:'library-1.3', ext:'aar')
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2815 次 |
| 最近记录: |