0

Here is my build.gradle file when I compile it always says 'cannot find symbol class HtmlFetcher' which is inside the de.jetwick.snacktory dependency

jar file of snacktory library is downloaded into local gradle cache but it is not including it into project. what might be a problem?

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
    maven {url "https://github.com/karussell/mvnrepo/raw/master/releases"}
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:+'
    compile 'de.jetwick:snacktory:1.1'
    compile fileTree(dir: 'libs', include: '*.jar')
}
user1831986
  • 583
  • 1
  • 8
  • 16
  • Check my answer in this link http://stackoverflow.com/questions/19063133/android-studio-marks-syntax-as-error-but-gradle-compiles/21263279#21263279 – Zohra Khan Jan 28 '14 at 18:26
  • I guess that would be not correct solution. I already added maven repo and I want gradle automatically add it into my project. If I add it manually why should I use gradle? – user1831986 Jan 28 '14 at 18:31
  • What version of Android Studio are you running? – Scott Barta Jan 28 '14 at 18:34
  • Do you make it work? I get a java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector; when I initialize fetcher HtmlFetcher fetcher = new HtmlFetcher(); – rubdottocom Mar 07 '14 at 13:34
  • If I remember correctly, updating android studio fixed the problem – user1831986 Mar 09 '14 at 15:06

2 Answers2

0

Upgrade to Android Studio 0.4.3. There are bugs with adding dependencies that have been fixed since 0.4.0.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
0
compile fileTree(dir: 'libs', include: '*.jar')

That is the same line I use to compile my libs directory. I'm not sure if it's the version, as I've been using the above gradle line since 0.3 or so, and it's worked fine.

The only other thing to check would be the location of your libs folder.

Your libs folder needs to be inside of your Module.

Android studio projects are the same as IntelliJ projects meaning that the directory structure should be: ProjectName/ModuleName/libs

That means you need a libs directory on the same level as your src directory and build.gradle file. Double check it's in the right location.

spierce7
  • 14,797
  • 13
  • 65
  • 106
  • That's not correct solution when you are using gradle for dependency management. You can use it only when you have a custom or non-maven repo packages. anyway thanks – user1831986 Jan 29 '14 at 04:56
  • Oops, I'm sorry. I misread your question. I thought the problem was coming from something in the libs directory. – spierce7 Jan 29 '14 at 05:59