我有一个库,该库曾经用作我未来的Android应用程序的核心项目。
我尝试在build.gradle中将其导出为fatJar
android.libraryVariants.all {
variant ->
def name = variant.buildType.name
if (name == BuilderConstants.DEBUG) {
return; // Skip debug builds.
}
def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompile
//Include Java classes
task.from variant.javaCompile.destinationDir
//Include dependent jars with some exceptions
task.from configurations.compile.findAll {
it.getName() != 'android.jar' && !it.getName().startsWith('junit') && !it.getName().startsWith('hamcrest')
}.collect {
it.isDirectory() ? it : zipTree(it)
}
artifacts.add('archives', task);
}
然后在gradle菜单中选择jarRelease
之后,我将该罐子导入到我的主项目中。
这是我在主项目中的依赖项:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('/Users/kunnguyen/Repos/test/coreproject/coreproject.jar@aar')
}
但是我似乎无法从coreproject
模块那边的类扩展过来。
请帮忙。预先感谢