I'm working on an android library project, that depends on exoplayer. This library going to be distributed manually as an aar (not through Maven repositories). For test purposes, I create a project and add aar as a new module as described in official documentation.
My problem that there is no exoplayer library as a dependency in a project and error occurred.
I tried to add exoplayer in aar using api and implementation:
api ("com.google.android.exoplayer:exoplayer:2.10.4") {
transitive = true
}
I added a new module to a project(File->new->New Module->import jar/aar), checked that there is included module in settings.gradle include ':app', ':my_module'
, added dependecy in app's gradle file implementation project(':my_module')
.
Now, I can use classes defined in my library, but a crash occurred when library trying to use exoplayer.
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.exoplayer2.Player$DefaultEventListener"
Bad solution:
I can ask users of my library manually add exoplayer as a dependency to there app, but I see a lot of problems with this approach.implementation "com.google.android.exoplayer:exoplayer:2.10.4"
My thought: It should be possible just to add a dependency to a library. I did some research and there are a lot of contradictions in answers. Someone said that jars should be shipped inside, someone said that there is a problem with dependencies when library added not through maven repository.
Question: How to add a dependency to my android library? Where I have a lack of knowledge to understand what's wrong? Any ideas, thoughts, references are appreciated.
p.s.
- android studio v3.5
- com.android.tools.build:gradle:3.5.0