0

I'm new to Android and Kotlin and I'm building a library but I have trouble packing it. How can you pack an .aar when you have another external dependicy in it? I need to parse some JSON, so I added Klaxon as a dependency in the module's build.gradle file like this

dependencies {
   implementation ('com.beust:klaxon:5.0.1')
}

I also generate a .pom file where this is listed as a dependency.

When trying to add this locally in a demo app that uses the library, I put the .arr and .pom file in the libs folder of the project and add the arr file as a dependency in the demo app build.gradle but for some reason the app can't see Klaxon.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation files('libs/connatixplayersdk-release.aar')
}

also added flatDir to the project build.gradle

allprojects {
    repositories {
        google()
        jcenter()

        flatDir {
            dirs 'libs'
        }
}

I tried to use transitive=true in my module build.gradle, but it doesn't seem to work

implementation ('com.beust:klaxon:5.0.1'){transitive=true}

Also, I saw this response, but it referes to an .aar with an .aar dependency

Mihai Fischer
  • 329
  • 2
  • 11
  • 1
    You can't do it – Gabriele Mariotti Aug 29 '19 at 06:22
  • @GabrieleMariotti yes, I think it's the same situation. do you have by any chance a how to publish to maven step by step tutorial somewhere? I found several, but they seemed to miss out things and adding that to my limited Android knowledge, didn't let me too far. and thanks a lot! – Mihai Fischer Aug 29 '19 at 11:26
  • Check: https://blog.autsoft.hu/publishing-an-android-library-to-mavencentral-in-2019/amp/ – Gabriele Mariotti Sep 01 '19 at 17:36
  • Similar question here https://stackoverflow.com/questions/70445716/app-crashes-due-to-module-library-dependency?noredirect=1#comment124527111_70445716 – abhishek maharajpet Dec 22 '21 at 17:21

0 Answers0