Search code examples
androidbuildandroid-r8kotlin-multiplatform-mobilekmm

BuildConfig is defines multiple times in a KMM project


I am wokring on a Kotlin Multiplatform Mobile (KMM) project and was trying to generate a signed release app bundle for the Android Application and came across this error

Caused by: com.android.tools.r8.internal.b: Type packageName.BuildConfig is defined multiple times

One BuildConfig is spotted in the Android app module, another is in the shared module, with the same package name.

This is from my app module Gradle

buildTypes {
    getByName("release") {
        isMinifyEnabled = false
    }
}

I haven't faced this issue for Building Debug Apk or App Bundle.


Solution

  • I'd try out the following:

    1. Ensure that your shared and app modules have different package names
    2. Try doing a clean-build/rebuild