在libs文件夹中的jar文件的Andr​​oid摇篮不习惯建设 [英] Jar files in libs folder are not used in Android Gradle build

查看:163
本文介绍了在libs文件夹中的jar文件的Andr​​oid摇篮不习惯建设的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始的摇篮构建系统为Android玩。

i just started to play with the gradle build system for Android.

但我不能建立我的项目之一。它依赖于库/文件夹中的罐子。

However i'm not able build one of my projects. It depends on a jar in the libs/ folder.

摇篮构建无法在 compileDebug 的任务,因为所有的jar文件的类人失踪。

Doing gradle build fails in the compileDebug task because all of the classes from the jar file are missing.

这是一个库项目!这是我的build.gradle文件:

It is a library project! Here is my build.gradle file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.2'
    }
}

apply plugin: 'android-library'

android {
    target='android-16'
    sourceSets {
        main {
            manifest {
                srcFile 'AndroidManifest.xml'
            }
            java {
                srcDir 'src'
            }
            res {
                srcDir 'res'
            }
            assets {
                srcDir 'assets'
            }
            resources {
                srcDir 'src'
            }
        }
    }
}

我失去了一些东西明显?

Am i missing something obvious?

Goddchen

推荐答案

刚刚找到自己的答案:

看起来像Android的摇篮插件的当前版本不查找在库/文件夹中的罐子。所以,你必须自己添加他们:

Seems like the current version of the Android Gradle plugin doesn't look for jars in the libs/ folder. So you have to add them yourself:

dependencies {
    compile files('libs/mylib.jar')
}

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

之内将这个这样的机器人命名空间:

android {
    target = "android-15"

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

这篇关于在libs文件夹中的jar文件的Andr​​oid摇篮不习惯建设的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆