Hi! I've migrated to the new MPP plugin. The proje...
# kotlin-native
a
Hi! I've migrated to the new MPP plugin. The project is an iOs/Android app. It works fine on my macbook, but when I try to compile Android app on my linux system, I receive a error:
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':adsmodule:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug'.
> java.lang.RuntimeException: java.util.zip.ZipException: duplicate entry: ru/subprogram/guitarsongs/ads/BannerAdFactory.class
Duplicate entry could be different after clean/rebuild. I use IDEA Ultimate 2018.3.5, tested kotlin version
1.3.21
and
1.3.30-eap-45
.
l
Is your project open source, or can you link a reproducing project?
a
I'm afraid not. But @svyatoslav.scherbina has access to the repository on bitbucket.org.
s
Is this issue related to Kotlin/Native? What happens if you remove iOS* presets from your Gradle projects?
a
@svyatoslav.scherbina I managed to solve the issue, thank you! The problem was in my gradle file of MPP module, which includes another MPP module:
Copy code
kotlin {
    targets {
//...
    }

    sourceSets {
        commonMain.dependencies {
            api project(':commonmodule')
        }

        androidMain.dependencies {
//            api project(':commonmodule')        <- here, redundant line
            implementation project(':sqlitex')
            implementation 'com.getkeepsafe.relinker:relinker:1.2.3'
        }
    }
}
Why it works on my macbook - I have no idea...
👍 1
Is it ok to declare dependency like that:
Copy code
apply plugin: 'kotlin-multiplatform'
apply plugin: 'com.android.library'
//...
kotlin {
//...
    targets {
//...
        fromPreset(presets.android, 'android')
    }
    sourceSets {
        commonMain.dependencies {
            implementation project(':commonmodule')
            implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
        }

        androidMain.dependencies {
            implementation project(':sqlitex')
            implementation 'com.getkeepsafe.relinker:relinker:1.2.3'
            implementation 'org.jetbrains.kotlin:kotlin-stdlib'
        }
    }
}
The
commonmodule
is MPP too
Copy code
apply plugin: 'kotlin-multiplatform'

kotlin {
    targets {
 //...
        fromPreset(presets.jvm, 'android')
    }

    sourceSets {
        commonMain.dependencies {
            implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
        }

        androidMain.dependencies {
            implementation 'org.jetbrains.kotlin:kotlin-stdlib'
        }
    }
}
I guess that something is wrong here... Why
kotlin-stdlib
is declared in both dependencies blocks (
commonMain
and
androidMain
), but
project(':commonmodule')
is declared only in the
commonMain
block? Is everything right here?
s
Why
kotlin-stdlib
is declared in both dependencies blocks (
commonMain
and
androidMain
), but
project(':commonmodule')
is declared only in the
commonMain
block? Is everything right here?
Does the project work properly without
kotlin-stdlib
dependency in
androidMain { ... }
?
a
No... I have a lot of "Unresolved reference" errors without this line (at least on my macbook. I can test in on my linux system in the evening, but I guess that result will be the same).
s
The original issue still doesn’t look related to Kotlin/Native or iOS. Have you tried to reproduce it with iOS targets removed?
a
Yes, the issue is reproduced with iOS targets removed. I think that the problem is in the new MPP plugin.