Open andannn opened 1 day ago
工程根目录的build.gradle文件下引入KotlinMultiplatform
alias(libs.plugins.kotlinMultiplatform).apply(false)
mediastore包的build.gradle下,修改配置 这部分是KMP的配置, 之后每个Module都需要同样的配置, 所以需要自定义一个gradle plugin。
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
}
}
sourceSets {
commonMain.dependencies {
}
commonTest.dependencies {
}
}
}
安卓sdk的配置 这部分是android library的配置, 需要整合一个gradle plugin
android {
defaultConfig.apply {
minSdk = 24
}
compileSdk = 34
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
namespace = "com.andannn.melodify.core.datastore"
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
https://developer.android.com/kotlin/multiplatform/datastore Migrate Proto to Preferences, because Proto is not support officially.
Now The app can run after this commit https://github.com/andannn/Melodify/pull/136/commits/7eed34d5dee4e46ad0f2d28d1f151b6ca33c5862