【发布时间】:2015-02-11 00:45:38
【问题描述】:
首先这是我在 Eclipse 中的 Java 构建路径:
这四个jar'common.jar,core.jar,framework.jar,layout.jar'是从Android源码中打包出来的,里面包含了一些开发者不能公开使用的类。他们不需要导出是因为它们用于作弊编译器。在 Eclipse 中一切正常。
现在我正在尝试使用 gradle 将我的项目导入 Android-Studio。我已将 jars 添加到依赖项中,但是我无法更改我的 jars 和 android jar 的编译顺序。我不能把这些jar放在android jar前面。我对gradle不熟悉,现在编译器在这些jar中找不到类。任何帮助将不胜感激! 这是我的 build.gradle:
apply plugin: 'android'
dependencies {
compile files('jars/common.jar')
compile files('jars/core.jar')
compile files('jars/framework.jar')
compile files('jars/layout.jar')
compile fileTree(dir: 'libs', include: '*.jar')
compile files('jars/animation_nineoldandroids_src.jar')
compile files('jars/json_simple_src.jar')
compile files('jars/jsoup-1.7.2-sources.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "21.1.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
【问题讨论】:
-
build.gradle 是 Eclipse 生成的。从 File->Export->Android->Generated Gradle build files,不是我的工作。
-
任何人都得到了适用于 Android Studio 的工作解决方案
标签: android android-studio gradle android-gradle-plugin