Gradle error with Android project added as a library (SlidingMenu) [package does not exist]

Enrichman picture Enrichman · May 20, 2013 · Viewed 12.1k times · Source

I've never used Gradle before so I'm completely lost!

I've added SlidingMenu as a library and I have access from my project to all the SlindingMenu stuff, but trying to compile will give me this error:

Gradle: package com.jeremyfeinstein.slidingmenu.lib does not exist

I'm using Android Studio (so IntelliJ) and this is my gradle.build

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'
dependencies {
    compile files('libs/android-support-v4.jar')
}
android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }
}

Thanks in advance

Answer

leadrien picture leadrien · May 21, 2013

Assuming you have added SlidingMenu.jar into libs folder, right click on it -> Add as library. Then change in gradle.build:

Before:

dependencies {
    compile files('libs/android-support-v4.jar')
}

After:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

This will include all your jar files.