简体   繁体   English

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

[英]Bundle third-party library in my .aar

I'm building an Android library for music streaming.我正在构建一个用于音乐流媒体的 Android 库。 It has ExoPlayer as dependency (excellent library btw!).它有ExoPlayer作为依赖项(顺便说一句,优秀的库!)。

We use this library for another project that we're also developing right now, in Xamarin.我们将此库用于我们目前也在 Xamarin 中开发的另一个项目。 Currently, we need to add both libraries (my .aar and a .jar for ExoPlayer).目前,我们需要添加两个库(我的 .aar 和 ExoPlayer 的 .jar)。 That's a bit annoying to be honest, I'd love to just drop my .aar in, and go.老实说这有点烦人,我很想把我的 .aar 放进去,然后去。

So two questions:所以两个问题:

  1. is there a way I can bundle the ExoPlayer inside my .aar, using gradle and stuff?有没有办法可以使用 gradle 和其他东西将 ExoPlayer 捆绑在我的 .aar 中? (I'm quite a beginner here, be thorough please) (我是这里的初学者,请彻底)
  2. I realise it might not be the best thing to do (dependency should be managed by app, blah blah blah), but really we will always test ExoPlayer and my lib together every time we update the former.我意识到这可能不是最好的事情(依赖应该由应用程序管理,等等等等),但实际上我们每次更新前者时都会一起测试 ExoPlayer 和我的库。 So is there a strong reason I should not bundle ExoPlayer in my lib, or is that ok?那么是否有充分的理由我不应该在我的库中捆绑 ExoPlayer,或者可以吗?

And here's my current gradle file.这是我当前的 gradle 文件。 Nothing exciting to look at though.不过,没有什么令人兴奋的。 But as I converted the initial app to a lib, maybe there's something odd, who knows...但是当我将初始应用程序转换为 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'
}

There are no solutions for this until this issue is solved, but a viable alternative for someone can be to bundle the .aar (s) singularly using the "Import .JAR/.AAR Package" while clicking on "New Module".在解决此问题之前没有解决方案,但对于某些人来说,一个可行的替代方案是在单击“新模块”的同时使用“导入 .JAR/.AAR 包”单独捆绑.aar (s)。

在此处输入图片说明

The only problem with this approach is that you can bundle only 1 AAR at a time in this way, so you need to create a module for each one of them.这种方法的唯一问题是您一次只能捆绑 1 个 AAR,因此您需要为每个 AAR 创建一个模块。


In alternative you can try with Kezong fat aar library:或者,您可以尝试使用 Kezong fat aar 库:

https://github.com/kezong/fat-aar-android https://github.com/kezong/fat-aar-android


声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android中使用第三方库时出现问题 - Problems using third-party library in Android 编写第三方付费库的包装,并尝试从我的.aar lib项目中隐藏第三方lib的.jar文件 - Writing wrapper of a third party paid library and trying to hide the .jar file of third party lib from my .aar lib project Android Studio:根据第三方库的来源制作应用程序 - Android Studio: make application depending on sources of third-party library Android Studio中没有方法签名(或如何添加第三方库) - No signature of method (or how to add a third-party library) in Android Studio 谷歌播放服务版本在应用程序中与第三方库发生冲突 - Google play services version conflict in app with third-party library 动态功能模块中的第三方库 - Third-party library inside dynamic feature module Android AAR第三方Jar - Android AAR third party jars 已安装的应用程序是否为第三方 - Installed application is third-party or not android库项目中第三方库的aar文件大小减小为0 - aar file size of third party library inside android library project reducing to 0 使用 android 应用程序包后未找到 Android 第三方库 - Android third party library not found after using android app bundle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM