Reputation: 597
Hi I am new to Android and Kotlin environment, I am from native iOS background.
I want to create a Kotlin MultiPlatform app and it is run-on both Android and iOS.
For this I am following this https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html
After complete the Updating Gradle Scripts process from the above documentation I am facing issue like:
Could not get unknown property 'iosX64' for KotlinTargetPreset container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.
and my build.gradle file path is /Kotlin_Practice/KTMPDemo/SharedCode/build.gradle
apply plugin: 'kotlin-multiplatform'
kotlin {
targets {
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
? presets.iosArm64 : presets.iosX64
fromPreset(iOSTarget, 'iOS') {
compilations.main.outputKinds('FRAMEWORK')
}
fromPreset(presets.jvm, 'android')
}
sourceSets {
commonMain.dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
androidMain.dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib'
}
}
}
// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations {
compileClasspath
}
Can I update / downgrade my Gradle ?? How can I fix this above issue? Thank you.
My system Configuration:
Mac mini (Late 2014), macOS High Sierra, v10.13.5.
Android Studio Android Studio 3.1.4
Build #AI-173.4907809, built on July 24, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Upvotes: 2
Views: 1929
Reputation: 1091
I had the same issue just now and by lack of answers I continued my search. Getting the example project running on first try meant there must've something of on my setup.
In my case it was not having the 1.3 Kotlin Gradle plugin version. You will have multiple .gradle files by now. Presumably your main-project one will have something like this:
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Make sure the kotlin-version points to a 1.3 one. I used the same as example project and I had a 1.2.71 before. Things started working for me after that. I'm sure there's much more hurdles to take, but this might get you a bit further.
Upvotes: 5