在 Android Studio 中使用自定义框架库(android.jar) [英] Use customized framework library(android.jar) within Android Studio
问题描述
我有自己的定制框架(android.jar),并想在 Android Studio 中使用它.我在 build.gradle 中有这样的描述:
I had my own customized framework(android.jar) and want to use it within Android Studio. I had description in my build.gradle like:
dependencies {
compile files('myandroid.jar')
}
但 Android Studio 仍然使用默认框架(android.jar).预期的情况就像Eclipse,我可以安排库的顺序.在Android Studio中,我只能安排外部库的顺序,与默认框架库无关.有没有办法让我自定义的 android.jar 比默认的有更高的顺序?
But Android Studio still use the default framework(android.jar). Expected situation is like Eclipse, I can arrange the order of libraries. In Android Studio, I can only arrange external libraries' order and have nothing to do with the default framework library. Is there a way to let my customized android.jar had higher order than the default one?
非常感谢!
推荐答案
将此行放在您的依赖项中:
Place this line inside your dependencies:
provided files('libs/myandroid.jar')
如果还是不行,那么我们可以添加我们的库来构建类路径.在应用程序的 build.gradle 中,添加以下内容:
If still not work, so we can add our library to build classpath. In application's build.gradle, add these:
allprojects {
repositories {
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs.add('-Xbootclasspath/p:app\\libs\\mylibs.jar')
}
}
}
我把 mylib.jar 放在 app/libs 中.IDE 上可能会显示一些错误,但应用程序的构建没有问题.
I placed mylib.jar is in app/libs. There maybe some errors display on IDE, but application's build will be OK.
这篇关于在 Android Studio 中使用自定义框架库(android.jar)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!