Gurupad Mamadapur [FH]
12/23/2019, 2:54 PMplugins {
id "com.android.library"
id 'org.jetbrains.kotlin.multiplatform'
}
repositories {
mavenCentral()
}
android {
compileSdkVersion(28)
buildToolsVersion = "28.0.3"
defaultConfig {
minSdkVersion(16)
targetSdkVersion(28)
}
}
kotlin {
android()
js {
browser {
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "io.ktor:ktor-client-core:$ktorVersion"
}
}
androidMain {
dependencies {
implementation kotlin('stdlib')
}
}
jsMain {
dependencies {
implementation kotlin('stdlib-js')
}
}
}
}
Here is the root build.gradle -
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
ext {
ktorVersion = "1.3.0-rc"
}
Error is -
> Task :shared:compileDebugKotlinAndroid FAILED
e: /Users/fabhotels/Development/testmpp/shared/src/commonMain/kotlin/common.kt: (1, 23): Unresolved reference: HttpClient
e: /Users/fabhotels/Development/testmpp/shared/src/commonMain/kotlin/common.kt: (3, 18): Unresolved reference: HttpClient
The sample project is available here - https://github.com/Protino/testmpp/tree/sample/ktornapperley
12/23/2019, 9:39 PMHannes
12/23/2019, 9:48 PMobject
from iOS side?
Let's say I have in commonMain a
object Foo
How can i call Foo
from iOS side?
If I try to use Foo directly I actually somehow access the Type, but not the singleton instance. Any idea?jdemeulenaere
12/24/2019, 3:39 PMclient/ <= Kotlin/JS subproject
|- build.gradle.kts <= What should I put here to allow client to depend on :shared ?
server/ <= Kotlin/JVM subproject
|- build.gradle.kts <= What should I put here to allow server to depend on :shared ?
shared/ <= Kotlin/Multiplatform subproject
|- build.gradle.kts
I tried to put this but it didn't work:
dependencies {
implementation(project(":shared"))
}
ansman
12/24/2019, 6:15 PMjs
target but I keep getting :module:jsTest NO-SOURCE
. My tests are in module/src/jsTest/kotlin
jdiaz
12/25/2019, 9:44 PMJoey
12/26/2019, 2:45 AM* What went wrong:
A problem occurred evaluating settings 'sample-kt-sharedlib'.
> Could not find method enableFeaturePreview() for arguments [GRADLE_METADATA] on settings 'sample-kt-sharedlib' of type org.gradle.initialization.DefaultSettings.
Any suggested solution to this? Im trying to upload a multiplatform lib to bintray. Thanks! B-)saket
12/26/2019, 5:26 PMOrhan Tozan
12/26/2019, 11:54 PMMarc Knaup
12/27/2019, 10:17 AMjdemeulenaere
12/27/2019, 1:55 PMBig Chungus
12/27/2019, 2:36 PMsteamstreet
12/27/2019, 6:50 PMBrendan Weinstein
12/27/2019, 8:25 PMAlexander
12/27/2019, 10:12 PMNikita Khlebushkin
12/28/2019, 10:15 PMaltavir
12/29/2019, 4:25 PMbasher
12/29/2019, 5:56 PMgetFoo()
, which gets translated to the val
foo
in Kotlin, is there a way to write an expect class that captures that? If I do:
expect class F {
val foo: Int
}
Kotlin (1.3.61) complains that the matching class in Java (via actual typealias F = MyJavaClass
) doesn't have that property. Is there some kind of annotation I need to use in my expect class
to make this work (so that when val foo
matches up with the Java getter)?Slackbot
12/30/2019, 9:23 AMKris Wong
12/30/2019, 3:27 PMNick Halase
12/30/2019, 6:04 PMStefMa
12/31/2019, 7:16 AMlib
and sample
.
The library uses some dependencies (ktor for instance). They all are declared as implementation
dependencies.
My sample should simply use the lib
as a dependency.
For this i added
commonMainImplementation(project(":lib"))
But if I run my jvm
sample (which has a main
method) I get:
java.lang.NoClassDefFoundError: io/ktor/client/HttpClientJvmKtWhich is strange because I do not share the
HttpClient
as a API. It is declared as internal
and therefore it should not be shared with other libraries...
To my question:
Is this setup possible? How should it work then? How do I have to declare my lib dependency in the sample?mzgreen
12/31/2019, 1:28 PMcommonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
And then in commonTest/kotlin/
directory I have this file:
class Test {
@Test
fun foo() {
assertEquals(1,2,"Test failed")
}
}
I run it ./gradlew :common:test
and I get errors like:
> Task :common:compileDebugUnitTestKotlinAndroid FAILED
e: .../common/src/commonTest/kotlin/Test.kt: (1, 20): Unresolved reference: Test
e: .../common/src/commonTest/kotlin/Test.kt: (2, 20): Unresolved reference: assertEquals
e: .../common/src/commonTest/kotlin/Test.kt: (6, 5): 'Test' is not an annotation class
e: .../common/src/commonTest/kotlin/Test.kt: (8, 9): Unresolved reference: assertEquals
Not sure what is going on.Kris Wong
12/31/2019, 3:19 PMKris Wong
12/31/2019, 4:09 PMserebit
12/31/2019, 4:39 PMsaket
01/01/2020, 12:24 AMspierce7
01/01/2020, 8:05 PMCannot upload checksum for module-maven-metadata.xml. Remote repository doesn't support sha-512
Does anyone know how to fix this?Kurt Renzo Acosta
01/02/2020, 3:23 AMmzgreen
01/02/2020, 11:20 AMsleep
method or its equivalent. Coroutines are multiplatform but do they support jvm target?
https://github.com/Kotlin/kotlinx.coroutines#multiplatform I see android, js and native here but no jvm.