Android Studio使用gradle添加.jar文件

时间:2013-11-06 16:25:40

标签: java android gradle android-studio

我正在尝试使用Android Studio处理Android应用程序。因此,我相应地设置了所有内容(据我所知)。

我的build.gardle(在CampusApp文件夹中)如下所示:

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

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.android.support:support-v4:13.0.0'
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.google.android.gms:play-services:3.1.36'
}

当我尝试运行时:

./gradlew clean && ./gradlew build

它给了我很多错误,说

错误:包XXXX不存在

/Users/foo/git/CampusAppProject/CampusApp/src/main/java/de/unitrier/caching/DiskLruImageCache.java:7: error: package com.android.volley.toolbox does not exist
    import com.android.volley.toolbox.ImageLoader;
[...]
100 errors 
:CampusApp:compileDebug FAILED
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':CampusApp:compileDebug'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

My Workspace dir看起来像:

enter image description here

任何想法?

[编辑] 它不仅没有发现凌空。它似乎是lib文件夹中的所有jar文件

1 个答案:

答案 0 :(得分:0)

原来这个libs文件夹位于错误的文件夹中。应该在/文件夹中。