https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

Guilherme Cordeiro

03/30/2021, 1:14 PM
Hello all! Good <insert part of the day on you timezone>! 😄 It might totally be ignorance on my part, but I am having trouble on the following multi-platform / multi-modules scenario: • I have base KMM modules, that only have external dependencies • And service KMM modules, which may depend on base modules and/or external dependencies • When I import my base modules locally (through
project(":mybasemodule")
) all goes well, project compiles, runs and I can publish the artifacts on my maven repository • When I publish my base modules and import them on the service modules as remote dependencies, Android Studio resolves them (through some .knm bridging files) but my compilation fails due
Unresolved Reference
to the objects/methods defined on my base module I am currently using only
Android
target (to limit my scope) and publishing android library variants besides the
common
default one.
Copy code
android {
        publishLibraryVariants("debug", "beta", "release")
    }
Also, I'm importing all base KMM module dependencies on
commonMain
only:
Copy code
val commonMain by getting {
            dependencies {
                api(
                    if (remoteDeps) Frameworks.Logging.lib //import from maven
                    else project(Frameworks.Logging.proj) //pont to local project
                )
                ...
            }
            ...
I'm using AS 4.1.3, with buildTools plugin 4.1.3 gradle 6.8.3 and Kotlin stdlib 1.4.21 Anyone has any idea on what I might be doing wrong? Thanks in advance for any ideas/advices 🙏
Copy code
const val targetSdk = 30
const val compileSdk = 30
const val minSupportedSDK = 21
const val buildToolsVersion = "30.0.3"
const val ndkVersion = "22.0.7026061"
and this is the android configuration applies on all the android libraries
Copy code
import com.luizalabs.pmob.megazord.gradle.Env

apply from: "$rootDir/buildScripts/signing-config.gradle"

android {
    compileSdkVersion Env.Android.compileSdk
    buildToolsVersion Env.Android.buildToolsVersion
    ndkVersion Env.Android.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion Env.Android.minSupportedSDK
        targetSdkVersion Env.Android.targetSdk
        versionCode Env.Build.versionCode
        versionName Env.Build.versionName

        consumerProguardFiles fileTree(dir: "$rootDir/buildScripts/proguard", include: ["*.pro"]).asList().toArray()
        externalNativeBuild.cmake.cppFlags ""
        ndk.abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"

        buildTypes {
            all {
                proguardFiles getDefaultProguardFile("proguard-android.txt")
                proguardFiles fileTree(dir: "$rootDir/buildScripts/proguard", include: ["*.pro"]).asList().toArray()
            }

            debug {
                signingConfig signingConfigs.debug
                debuggable true
                minifyEnabled false
            }

            beta {
                signingConfig signingConfigs.beta
                debuggable true
                minifyEnabled false
            }

            release {
                signingConfig signingConfigs.release
                debuggable false
                minifyEnabled false
                crunchPngs false
            }
        }
    }

    packagingOptions {
        exclude "junit"
        exclude "LICENSE.txt"
        exclude "LICENSE-junit.txt"
        exclude "META-INF/DEPENDENCIES"
        exclude "META-INF/*.kotlin_module"
        exclude "META-INF/LICENSE"
        exclude "META-INF/LICENSE.txt"
        exclude "META-INF/MANIFEST.MF"
        exclude "META-INF/NOTICE"
        exclude "META-INF/NOTICE.txt"
        exclude "META-INF/proguard/coroutines.pro"
        exclude "META-INF/rxjava.properties"
        exclude "META-INF/services/javax.annotation.processing.Processor"
        exclude "mockito-extensions"
    }
}
3 Views