Android Library seems to loose some informations upon compilation

Viewed 38

I was writing my own navigation for compose, by that ive created a seperate project that contains the library. after some time i could reuse the project in an compose desktop application. after some time i recieved emails about my project not running on andoid anymore. ive got this stacktrace: (other versions results in othewr method names but everytime method not found)

No virtual method setUi(Lkotlin/jvm/functions/Function5;)V in class Lcom/nom/rougthnav/ScreenConfiguration; or its super classes (declaration of 'com.nom.rougthnav.ScreenConfiguration' appears in /data/data/com.nom.myapplication/code_cache/.overlay/base.apk/classes.dex)
    at com.nom.myapplication.MainActivity$onCreate$1$1$1$router$2$1.invoke(MainActivity.kt:33)
    at com.nom.myapplication.MainActivity$onCreate$1$1$1$router$2$1.invoke(MainActivity.kt:31)
    at com.nom.rougthnav.Router.screen(Router.kt:75)
    at com.nom.rougthnav.Router.screen(Router.kt:47)

this keeps appearing only if i use this as an aar library, so ive researched about this. ive analyzed my aar files and the final apk that got installed everywhere is the method present and i have no dependency version conflict. if i use the files directly in those projects its working like a charm.

ive thought that this might be resolved if i use another set of dependencies, so ive created a new sample project barely used anything, but got this error again in any version of my aar file.

an example: ive got this interface for the configuration:

interface RouterScope<K> {
    fun <T> screen(
        tag: K,
        modelFactory: () -> T,
        block: @Composable (model: T, back: Back, nav: Nav<K>) -> Unit
    )

    var initialTag: K
    var link: String
    fun route(tag: K, initial: K, block: RouterScope<K>.() -> Unit)
    var tagConverter: ((String) -> K)?
}

but the screen method keeps disappearing. im wondering if this is linked with the composeable annotation. But the composeable annotation is used the same way in other android libs.

Any hint appreciated, im finally stuck. here is my build.gradle.kts:

plugins {
    id("org.jetbrains.kotlin.android")
    id("com.android.library")
    `maven-publish`
}

android {
    compileSdk = 30

    defaultConfig {
//        applicationId = "com.nom.rougthnav"
        minSdk = 27
        targetSdk = 30
//        versionCode = 1
//        versionName = "1.0"
        version = "1.6"
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = "11"
    }
}

dependencies {

    implementation("androidx.core:core-ktx:1.6.0")
    implementation("androidx.appcompat:appcompat:1.3.1")
    implementation("com.google.android.material:material:1.4.0")
    val compose = "1.0.3"
    implementation("androidx.compose.ui:ui:$compose")
    implementation("androidx.compose.ui:ui-tooling-preview:$compose")
    implementation("androidx.compose.ui:ui-tooling:$compose")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.3")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
}

afterEvaluate {
    publishing {
        publications {
            register("release",MavenPublication::class){
                from(components["release"])
                groupId = "com.nom.roughtnav"
                artifactId = "core"
                version = "${project.version}"
            }
//
        }
    }
}
0 Answers
Related