Reputation: 523
I have been trying to use the SlidingMenu library in my Android Studio project following the guide provided in this question:
How to import slidingmenu on Android Studio?
I've been able to obtain the described file structure and sync&build the project without errors. Yet, when trying to import the Sliding Menu to my apps source files, I'm getting a symbol resolve error.
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu; // Error message: Cannot resolve symbol 'SlidingMenu'
import com.jeremyfeinstein.slidingmenu.lib.BuildConfig;
The second import is the only one suggested by Android Studio but I can't even find the BuildConfig file in my project when following the given path.
What do I need to change to be able to import all the classes in com.jeremyfeinstein.slidingmenu.lib
to my own classes?
My apps gradle files looks like this:
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')
}
The SlidingMenu gradle file:
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'
}
}
}
Project settings gradle:
include ":libraries:SlidingMenu", ':app'
Upvotes: 4
Views: 3211
Reputation: 18243
Get the AAR port of the library (v1.3).
The GitHub Pages is down, so you'll have to import that AAR manually:
Top build.gradle file:
repositories {
flatDir {
dirs 'libs'
}
}
Place the AAR file in the libs folder of your module, then in your module build.gradle file:
dependencies {
compile(name:'library-1.3', ext:'aar')
}
Upvotes: 5