简体   繁体   English

Gradle不会自动将jar添加到项目中

[英]Gradle is not automatically adding jar into project

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 这是我的build.gradle文件,在我编译时始终说“找不到符号类HtmlFetcher”,它位于de.jetwick.snacktory依赖项内

jar file of snacktory library is downloaded into local gradle cache but it is not including it into project. 小吃库的jar文件已下载到本地gradle缓存中,但不包含在项目中。 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')
}

Upgrade to Android Studio 0.4.3. 升级到Android Studio 0.4.3。 There are bugs with adding dependencies that have been fixed since 0.4.0. 自从0.4.0起,存在添加依赖项的错误。

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

That is the same line I use to compile my libs directory. 那是我用来编译我的libs目录的同一行。 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. 我不确定是否是版本,因为从0.3左右开始我就一直在使用上面的gradle行,所以效果很好。

The only other thing to check would be the location of your libs folder. 唯一要检查的另一件事是libs文件夹的位置。

Your libs folder needs to be inside of your Module. 您的libs文件夹需要位于模块内部。

Android studio projects are the same as IntelliJ projects meaning that the directory structure should be: ProjectName/ModuleName/libs Android studio项目与IntelliJ项目相同,这意味着目录结构应为: ProjectName/ModuleName/libs

That means you need a libs directory on the same level as your src directory and build.gradle file. 这意味着您需要一个与src目录和build.gradle文件处于同一级别的libs目录。 Double check it's in the right location. 仔细检查它在正确的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM