目前,我的Android应用程序项目是针对本地库项目进行编译的,如下所示:
// build.gradle
dependencies {
compile project(':Library-Project')
compile files('libs/library.jar') // Resolve into this if Library-Project is not available
}
本地库项目内置在
library.jar
中,并放置在libs
文件夹中。如果不存在本地项目而不用注释
library.jar
代替对jar进行编译,是否有办法回退compile project(':Library-Project')
Artifact ?
最佳答案
使用了一种更动态的方法,应针对其实际编译依赖项。
dependencies {
// Check if the local project exists, and compile against that if it does
if ( new File("/Library-Project").exists() )
{
compile project(':Library-Project')
}
// Local project DNE, compile against JAR file
else
{
compile files('libs/library.jar')
}
}
自动编译
/libs
文件夹中所有JAR文件的另一种方法是在dependencies
块中添加以下行:compile fileTree(include: ['*.jar'], dir: 'libs')
关于android - 在Android Studio中将Gradle依赖关系解析为本地JAR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41028430/