albertgao
02/28/2018, 9:48 AMcommon
module: Only contain expect class
and no implementation just like plain interface
. Build with plugin kotlin-platform-common
- `platformsjvm`: actual implementation on jvm. It generates library, and I tried in Android Studio, it works. Build with plugin kotlin-platform-jvm
project-lib:
- `common`: It contains code which mean to be the same across all platforms. But it depends on the API from common
of project-platforms
. Which means it just depends on the common
code rather than the actual implementation of a certain platform. Build with plugin kotlin-platform-common
- `forBuild:JVM`: Its purpose is for testing common
and build for jvm. So it just embed the source code from common
, and add the generated jar file from project-platforms :platforms:jvm
as dependencies and do the test and build. The testing part works, it will compile and run the test from common
. And build without error.
Now the problem is when use the generated jar file from forBuild:JVM
in Android studio. It said: java.lang.NoClassDefFoundError: Failed resolution of: Lnz/salect/kotlinidiom/Platform; Caused by: java.lang.ClassNotFoundException: Didn't find class "nz.salect.kotlinidiom.Platform" on path: DexPathList[[zip file "/data/app/nz.salect.handset-1/base.apk", zip file "/data/app/nz.salect.handset-1/split_lib_dependencies_apk.apk"],nativeLibraryDirectories=[/data/app/nz.salect.handset-1/lib/x86, /system/lib, /vendor/lib]]
And the Platform
class is from project-platforms
which already add its jar file as dependencies.
I tried built with either kotlin-platform-jvm
or org.jetbrains.kotlin.jvm
, both yield the same error.
What am I missing here?anton.bannykh
02/28/2018, 9:55 AMalbertgao
02/28/2018, 8:21 PMproject-lib
. I am not fully agree with this change due to the fact that KMP is still pretty new, but I just think it should work because it is really isn’t that complex, so I decide to give it a try. 🙂 I think I miss something here.forBuild:JVM
, I just embed the whole source code from project-lib:common
, project-platforms:common
and project-platforms:jvm
, and use kotlin-platform-jvm
to compile the code. It works fine now. And for the test, I just embed the tests from project-lib:common
, it all works.ilya.gorbunov
03/04/2018, 5:44 AM:platforms:jvm
in forBuild:jvm
project?albertgao
03/04/2018, 7:11 AMcompile files('../../project-platforms/build/platforms-jvm.jar')
, but it doesn’t work as I described in the post, so I just embed the source code instead, then it works.ilya.gorbunov
03/04/2018, 7:39 AMalbertgao
03/04/2018, 9:30 AMPlatform.class
.
But when I just compile with the generated jar file from project-platforms :platforms:jvm
( compile files(“jvm-1.0.jar”)), it doesn’t contain that Platform.class
in the result.
This is why android couldn’t resolve it.
And I checked the jar from project-platforms :platforms:jvm
, it indeed contains the Platform.class
.