1

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
Runny
  • 48
  • 7
  • What you can do is distribute it as a local maven repository. The .aar together with a pom.xml containing the dependencies is packed in a directory. In the project gradle file, this directory is referenced as a repo and the module gradle file, it's referenced as any other dependency. Would that be an option? – Michiel Sep 19 '19 at 07:40
  • @Michiel I don't have experience in local maven repositories and it's pitfalls. I'll try to look forward to this direction and get back here later. Thanks. – Runny Sep 19 '19 at 10:05

0 Answers0