Hi guys. I’m to trying to port existing android ap...
# multiplatform
g
Hi guys. I’m to trying to port existing android app to mpp project and faced with gradle issue in build.gradle (:app)
> No signature of method: build_3j43qbq595kltehrfrix0ljuq.android() is applicable for argument types: (build_3j43qbq595kltehrfrix0ljuq$_run_closure1) values: [build_3j43qbq595kltehrfrix0ljuq$_run_closure1@7b98d7c]
Could you help me with that? Full build.gradle file is here
k
the error itself is quite cryptic, but you're applying KMP to an app module, which doesn't seem to make the most sense
when we think of building KMPP, which think of building a library which can be added as a dependency to another project
g
I rely on an official mpp sample from JetBrains. It uses kmpp in android app module https://github.com/Kotlin/mpp-example/blob/972783c080c66e7628f190775674891c20c871b3/androidApp/build.gradle.kts
k
that is quite strange, because that module doesn't actually have any KMP source sets
i don't see why they're applying the plugin at all
g
@StefMa could you take a look please? You’re the single contributor to that project 😬
I’ve downgraded to gradle 5.6.4 and agp 3.6.3 now I’m getting error: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ full stacktrace Fyi I’m not using gson in my project
s
Hi, this sample is a little bit outdated I guess... Without looking fuhrter into it, maybe this official guide will help you a little bit more? https://play.kotlinlang.org/hands-on/Targeting%20iOS%20and%20Android%20with%20Kotlin%20Multiplatform/01_Introduction As already said, it doesn't make any sense to apply the plugin to your application module. There you don't want (I can not) share code. It has to be applied to a module where do you apply the com.android.library plugin.
👍 1
r
It can be applied, but it's not usually what you want. It doesn't scale as well as having the android UI in a separate android-only module
1
r
So it should work, and author's issue should be unrelated to the fact of application mpp plugin to app?
Though @gabin says he resolved the issue by using mpp plugin only in library module, and JSON parsing one by using AGP 4.0.0 with Gradle 6.1.1. Strange. Okay, good to know it can happen.
Do you guys use
org.jetbrains.kotlin.js
and
org.jetbrains.kotlin.native
in app modules instead of
multiplatform
same way as `jvm`/`android` ones?