4

I'm building an Android library for music streaming. It has ExoPlayer as dependency (excellent library btw!).

We use this library for another project that we're also developing right now, in Xamarin. Currently, we need to add both libraries (my .aar and a .jar for ExoPlayer). That's a bit annoying to be honest, I'd love to just drop my .aar in, and go.

So two questions:

  1. is there a way I can bundle the ExoPlayer inside my .aar, using gradle and stuff? (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. So is there a strong reason I should not bundle ExoPlayer in my lib, or is that ok?

And here's my current gradle file. Nothing exciting to look at though. But as I converted the initial app to a lib, maybe there's something odd, who knows...

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'
}
Zoe
  • 27,060
  • 21
  • 118
  • 148
aspyct
  • 3,625
  • 7
  • 36
  • 61
  • Try having a look at these resources: http://stackoverflow.com/questions/24075356/how-do-i-ship-an-android-library-aar-with-remote-dependencies-gradle, http://stackoverflow.com/questions/26828163/how-to-release-an-aar-with-another-android-library-project-dependency, http://stackoverflow.com/questions/22795455/transitive-dependencies-not-resolved-for-aar-library-using-gradle – chRyNaN Mar 21 '16 at 16:44
  • Thanks for the links! Unfortunately, either they don't work, or I'm (so far) unable to apply them correctly... Will keep looking! – aspyct Mar 21 '16 at 17:15
  • Hi @aspyct , have you been able to bundle the dependency by now? Can you post a solution? Best – Giehl Man Oct 10 '16 at 12:11
  • @GiehlMan Yes, but I don't have time to write a full-fledge answer right now. Have a look at https://github.com/adwiv/android-fat-aar , that's what I used, and it worked fine. – aspyct Oct 10 '16 at 12:18
  • @aspyct: Di you find a solution for this. I am stuck with the same use case and fat.aar which is one of the solutions doesn't work for me. – Sid Feb 02 '17 at 15:07
  • fat.aar works fine for me so far, so I didn't look any further. Any details on how it doesn't work for you? – aspyct Feb 06 '17 at 10:10

1 Answers1

3

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".

enter image description here

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.


In alternative you can try with Kezong fat aar library:

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


MatPag
  • 41,742
  • 14
  • 105
  • 114