在我的.aar中捆绑第三方库

问题描述 投票:2回答:1

我正在构建一个用于音乐流媒体的Android库。它有ExoPlayer作为依赖(优秀的图书馆顺便说一句!)。

我们将这个库用于我们现在正在Xamarin开发的另一个项目。目前,我们需要添加两个库(我的.aar和.jar用于ExoPlayer)。说实话,这有点烦人,我喜欢把我的.aar放进去,然后走了。

所以有两个问题:

  1. 有没有办法可以使用gradle和东西将ExoPlayer捆绑在我的.aar中? (我在这里相当初学者,请彻底请)
  2. 我意识到它可能不是最好的事情(依赖应该由app管理,等等等等),但实际上我们每次更新前者时都会一直测试ExoPlayer和我的lib。那么有一个强有力的理由我不应该在我的lib中捆绑ExoPlayer,还是那样可以?

这是我当前的gradle文件。没什么好看的。但是当我将最初的应用程序转换为lib时,也许有些奇怪的东西,谁知道......

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ('com.google.android.exoplayer:exoplayer:r1.5.6')
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    compile 'com.android.support:appcompat-v7:23.2.0'
}
android jar android-gradle exoplayer aar
1个回答
1
投票

this issue解决之前没有解决方案,但是对于某人来说,一个可行的替代方案是使用“导入.JAR / .AAR包”单独捆绑.aar,同时单击“New Module”。

enter image description here

这种方法的唯一问题是,您可以通过这种方式一次捆绑1个AAR,因此您需要为每个AAR创建一个模块。


另一种方法是尝试使用Mobbeel fat-aar插件,你可以在这里找到:

https://github.com/Mobbeel/fataar-gradle-plugin

它是目前唯一支持Android Gradle Plugin 3.1.X的产品,支持AGP 3.2和3.3跟踪here。它支持更多高级功能,但并非所有功能都正常工作(您需要针对特定​​用例进行尝试,看看它是否有效)


© www.soinside.com 2019 - 2024. All rights reserved.