How to add the lib?
vdcast opened this issue · comments
Hello!
I'm trying to add the lib and use it to do some pie charts.
I added dependencies and synced project (maybe some of them in wrong place).
But I think it's not working, cause I can't import PieChart or any other composable from the lib.
Can you mention where exactly I need to add?
Here is my build.gradle shared module:
plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
id("com.squareup.sqldelight")
}
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "17"
}
}
}
targets.withType(org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget::class.java).all {
binaries.withType(org.jetbrains.kotlin.gradle.plugin.mpp.Framework::class.java).all {
export("dev.icerock.moko:mvvm-core:0.16.1")
export("io.github.thechance101:chart:Beta-0.0.5")
}
}
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.material3)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation("androidx.datastore:datastore-preferences-core:1.1.0-dev01")
implementation("com.squareup.sqldelight:runtime:1.5.5")
implementation("com.squareup.sqldelight:coroutines-extensions:1.5.5")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
implementation("org.jetbrains.kotlinx:atomicfu:0.17.3")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
}
}
val androidMain by getting {
dependencies {
api("androidx.activity:activity-compose:1.8.0")
api("androidx.appcompat:appcompat:1.6.1")
api("androidx.core:core-ktx:1.12.0")
implementation("com.squareup.sqldelight:android-driver:1.5.5")
implementation("io.github.thechance101:chart:Beta-0.0.5")
}
}
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependencies {
implementation("com.squareup.sqldelight:native-driver:1.5.5")
}
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
}
}
android {
compileSdk = (findProperty("android.compileSdk") as String).toInt()
namespace = "com.project"
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)
}
}
sqldelight {
database("AppDatabase") {
packageName = "com.data.database"
sourceFolders = listOf("sqldelight")
}
}
dependencies {
implementation("androidx.compose.material3:material3:1.1.2")
implementation("androidx.core:core:1.10.1")
commonMainApi("dev.icerock.moko:mvvm-core:0.16.1")
commonMainApi("dev.icerock.moko:mvvm-compose:0.16.1")
commonMainApi("dev.icerock.moko:mvvm-flow:0.16.1")
commonMainApi("dev.icerock.moko:mvvm-flow-compose:0.16.1")
}
and build.gradle project:
buildscript {
dependencies {
classpath("com.android.tools.build:gradle:8.1.2")
classpath("com.squareup.sqldelight:gradle-plugin:1.5.5")
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.17.3")
}
}
plugins {
kotlin("multiplatform").apply(false)
id("com.android.application").apply(false)
id("com.android.library").apply(false)
id("org.jetbrains.compose").apply(false)
}
allprojects {
apply(plugin = "kotlinx-atomicfu")
}
It was fixed by adding in build.gradle project level
repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
and added dependencies in commonMain sources in build.gradle shared module:
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.thechance101:chart:Beta-0.0.5")
}
}
}