a8496f08ee
According to https://developer.android.com/build/jdks we should: 1. [use JDK 17 for API 34](https://developer.android.com/build/jdks#compileSdk) 2. [use toolchain](https://developer.android.com/build/jdks#toolchain): ``` We recommend that you always specify the Java toolchain, and either ensure that the specified JDK is installed, or add a toolchain resolver to your build. ``` As we don't want to force people to have JDK 17 on their machine, we apply toolchain resolver that is recommended by Gradle: ``` id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0") ``` ## Test 1. Remove JDK 17 from the computer, remove `jvmToolchain(17)` 2. Run `./gradlew assembleDebug` 3. It should fail with: ``` > Could not create task ':androidApp:compileDebugJavaWithJavac'. > Failed to calculate the value of task ':androidApp:compileDebugJavaWithJavac' property 'javaCompiler'. > No matching toolchains found for requested specification: {languageVersion=17, vendor=any, implementation=vendor-specific} for WINDOWS on x86_64. > No locally installed toolchains match and toolchain download repositories have not been configured. ``` 4. restore `jvmToolchain(17)` 5. Run `./gradlew assembleDebug` again 6. It should succeed ## Issues Fixes https://github.com/JetBrains/compose-multiplatform/issues/3615
69 lines
1.9 KiB
Plaintext
69 lines
1.9 KiB
Plaintext
plugins {
|
|
kotlin("multiplatform")
|
|
id("com.android.library")
|
|
id("org.jetbrains.compose")
|
|
}
|
|
|
|
kotlin {
|
|
androidTarget()
|
|
|
|
listOf(
|
|
iosX64(),
|
|
iosArm64(),
|
|
iosSimulatorArm64()
|
|
).forEach { iosTarget ->
|
|
iosTarget.binaries.framework {
|
|
baseName = "shared"
|
|
isStatic = true
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
val commonMain by getting {
|
|
dependencies {
|
|
implementation(compose.runtime)
|
|
implementation(compose.foundation)
|
|
implementation(compose.material)
|
|
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
|
|
implementation(compose.components.resources)
|
|
}
|
|
}
|
|
val androidMain by getting {
|
|
dependencies {
|
|
api("androidx.activity:activity-compose:1.7.2")
|
|
api("androidx.appcompat:appcompat:1.6.1")
|
|
api("androidx.core:core-ktx:1.10.1")
|
|
}
|
|
}
|
|
val iosX64Main by getting
|
|
val iosArm64Main by getting
|
|
val iosSimulatorArm64Main by getting
|
|
val iosMain by creating {
|
|
dependsOn(commonMain)
|
|
iosX64Main.dependsOn(this)
|
|
iosArm64Main.dependsOn(this)
|
|
iosSimulatorArm64Main.dependsOn(this)
|
|
}
|
|
}
|
|
}
|
|
|
|
android {
|
|
compileSdk = (findProperty("android.compileSdk") as String).toInt()
|
|
namespace = "com.myapplication.common"
|
|
|
|
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
|
|
sourceSets["main"].res.srcDirs("src/androidMain/res")
|
|
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
|
|
|
|
defaultConfig {
|
|
minSdk = (findProperty("android.minSdk") as String).toInt()
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
kotlin {
|
|
jvmToolchain(17)
|
|
}
|
|
}
|