Closed mpivchev closed 4 years ago
Hello, could you please try the following:
Reaktive
dependency specifications from platform specific source sets. So only keep Reaktive
dependencies for commonMain
source set, no need to specify them for any other source set like androidMain
or iOSMain
.I removed deps from androidMain but now GraphQL cannot resolve. It throws a Unresolved reference: GraphQlOperation
. In the docs of GraphQL it says I need to include the android specific Reaktive deps for it to work. Not sure if it's related to this.
Current config:
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutinesVersion")
implementation("com.badoo.reaktive:reaktive:$reaktiveVersion")
implementation("com.badoo.reaktive:reaktive-annotations:$reaktiveVersion")
implementation("com.badoo.reaktive:coroutines-interop:$reaktiveVersion")
implementation("suparnatural-kotlin-multiplatform:graphql-metadata:$graphQLVersion")
implementation("suparnatural-kotlin-multiplatform:rx-runtime-reaktive-metadata:$graphQLVersion")
}
sourceSets["androidMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")
// implementation("com.badoo.reaktive:reaktive-android:$reaktiveVersion")
// implementation("com.badoo.reaktive:reaktive-annotations-android-debug:$reaktiveVersion")
// implementation("com.badoo.reaktive:coroutines-interop-android-debug:$reaktiveVersion")
implementation("suparnatural-kotlin-multiplatform:graphql-android-debug:$graphQLVersion")
implementation("suparnatural-kotlin-multiplatform:graphql-android:$graphQLVersion")
// implementation("suparnatural-kotlin-multiplatform:rx-runtime-reaktive-android-debug:$graphQLVersion")
// implementation("suparnatural-kotlin-multiplatform:rx-runtime-reaktive-android:$graphQLVersion")
}
Ok, now the configuration of Reaktive is correct. Next, seems that the GraphQL library is published without Gradle Metadata, so separate configurations per source set are required. Your configuration here appears to be correct as well.
What is not correct - you have to apply com.android.library
plugin and configure it as described here. You will need to do something like this:
plugins {
kotlin("multiplatform")
id("com.android.library")
// Other plugins
}
android {
compileSdkVersion(28)
// More config here
}
// More config here
Closing the issue. Feel free to reopen if you have any problem resolving Reaktive dependencies.
@arkivanov Still getting the error:
Could not find com.badoo.reaktive:reaktive:1.1.13. Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/badoo/reaktive/reaktive/1.1.13/reaktive-1.1.13.pom
- https://dl.bintray.com/kotlin/kotlinx/com/badoo/reaktive/reaktive/1.1.13/reaktive-1.1.13.pom
- https://dl.google.com/dl/android/maven2/com/badoo/reaktive/reaktive/1.1.13/reaktive-1.1.13.pom
- https://jcenter.bintray.com/com/badoo/reaktive/reaktive/1.1.13/reaktive-1.1.13.pom Required by: project :android > project :shared
Shared build.gradle:
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
}
kotlin {
jvm("android")
//select iOS target platform depending on the Xcode environment variables
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iOSTarget("ios") {
binaries {
framework {
baseName = "shared"
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
implementation("com.badoo.reaktive:reaktive:1.1.13")
}
}
val androidMain by getting {
dependsOn(commonMain)
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
}
}
}
val packForXcode by tasks.creating(Sync::class) {
val targetDir = File(buildDir, "xcode-frameworks")
//selecting the right configuration for the iOS framework depending on the Xcode environment variables
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets.getByName<KotlinNativeTarget>("ios").binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
from({ framework.outputDirectory })
into(targetDir)
/// generate a helpful ./gradlew wrapper with embedded Java path
doLast {
val gradlew = File(targetDir, "gradlew")
gradlew.writeText("#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n")
gradlew.setExecutable(true)
}
}
tasks.getByName("build").dependsOn(packForXcode)
Root build.gradle:
buildscript {
val kotlinVersion: String by extra
val gradleAndroidVersion: String by extra
repositories {
maven("https://kotlin.bintray.com/kotlinx")
maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://dl.bintray.com/badoo/maven")
google()
jcenter()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("com.android.tools.build:gradle:$gradleAndroidVersion")
}
}
allprojects {
repositories {
mavenCentral()
maven("https://dl.bintray.com/kotlin/kotlinx")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
google()
jcenter()
}
}
tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}
Hey @Drjacky, according to the error Reaktive's repository is not in the list of checked repositories. I think you need to add Reaktive's repository in your root build.gradle
as follows:
allprojects {
repositories {
...
maven("https://dl.bintray.com/badoo/maven")
}
}
Let me know if you if it helps.
@arkivanov Yes, fixed, thanks.
My fault, I had put it in buildscript
scope not in allprojects
.
Setting up the dependencies for this lib gives me the following errors:
It seems something gets confused about the build types?
Here's the multiplatform gradle confiig:
The app gradle config:
I tried changing the
implementation(project(":mobile-core"))
toimplementation(project(":mobile-core", configuration = "default"))
but that makes it so the Android implementation can't find the shared code.Any ideas how this can be fixed?