我正在导出一个aar库供我的Unity项目使用。我的aar对aar本身未包含的android库有很多依赖性。我认为最好将它们保持分开,以免与其他库发生冲突,但是我仍然需要将它们全部收集起来并放在Plugins / Android文件夹中。
我是否可以使用gradle命令收集我的依赖项,并将其与构建的aar一起放入文件夹中?这些都是我相信我图书馆所依赖的东西
这是我的gradle文件。
//indicates that this is a library
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
sourceSets {
main {
//Path to your source code
java {
srcDir 'src/main/java'
}
}
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compileOnly fileTree(include: ['*.jar'], dir: 'libs')
//androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
// exclude group: 'com.android.support', module: 'support-annotations'
//})
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
testImplementation 'junit:junit:4.12'
compileOnly files('libs/classes.jar')
compileOnly files('libs/libmessaging_unity_player_activity.jar')
def work_version = "1.0.0-alpha02"
implementation "android.arch.work:work-runtime:$work_version"
// use -ktx for Kotlin
}
//task to delete the old jar
task deleteOldJar(type: Delete) {
delete 'default/AndroidPlugin.jar'
}
//task to export contents as jar
task exportJar(type: Copy) {
from('build/intermediates/bundles/default/')
into('libs/jars')
include('classes.jar')
///Rename the jar
rename('classes.jar', 'AndroidPlugin.jar')
}
exportJar.dependsOn(deleteOldJar, build)
//task to delete the old jar
task deleteOldAAR(type: Delete) {
}
//task to export contents as jar
task exportAAR(type: Copy) {
from('build/outputs/aar/')
into('libs/aars')
include('app-debug.aar')
///Rename the jar
rename('app-debug.aar', 'AndroidPlugin.aar')
}
exportAAR.dependsOn(deleteOldAAR, build)