Commit cf79f399 authored by jiangyh's avatar jiangyh

新增一个lib

parent 99e28c21
...@@ -35,6 +35,7 @@ kotlin { ...@@ -35,6 +35,7 @@ kotlin {
sourceSets { sourceSets {
androidMain.dependencies { androidMain.dependencies {
implementation(libs.androidx.activity.compose) implementation(libs.androidx.activity.compose)
implementation(project(":lib-arith"))
} }
commonMain.dependencies { commonMain.dependencies {
} }
......
...@@ -27,7 +27,16 @@ class MainActivity : ComponentActivity() { ...@@ -27,7 +27,16 @@ class MainActivity : ComponentActivity() {
textSize = 24f textSize = 24f
} }
val resultAdd = com.example.arith.Arith.add(7, 3)
val resultSub = com.example.arith.Arith.sub(7, 3)
val addView = TextView(this).apply {
text = "Add is ${resultAdd}, Sub is ${resultSub}"
textSize = 24f
}
root.addView(msgView) root.addView(msgView)
root.addView(addView)
setContentView(root) setContentView(root)
} }
......
...@@ -11,4 +11,6 @@ org.gradle.caching=true ...@@ -11,4 +11,6 @@ org.gradle.caching=true
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
android.useAndroidX=true android.useAndroidX=true
org.gradle.java.home=/Users/jiangyuhuan/zulu-17.jdk/Contents/Home org.gradle.java.home=/Users/jiangyuhuan/zulu-17.jdk/Contents/Home
\ No newline at end of file kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
kotlin.mpp.applyDefaultHierarchyTemplate=false
\ No newline at end of file
plugins {
id("org.jetbrains.kotlin.multiplatform")
id("com.android.library")
}
kotlin {
androidTarget()
iosArm64()
iosSimulatorArm64()
iosX64()
sourceSets {
val commonMain by getting
val androidMain by getting
val iosMain by creating { dependsOn(commonMain) }
val iosArm64Main by getting { dependsOn(iosMain) }
val iosSimulatorArm64Main by getting { dependsOn(iosMain) }
val iosX64Main by getting { dependsOn(iosMain) }
}
}
android {
namespace = "com.example.arith"
compileSdk = 34
defaultConfig { minSdk = 24 }
}
\ No newline at end of file
<manifest package="com.example.arith" />
\ No newline at end of file
package com.example.arith
object Arith {
fun add(a: Int, b: Int): Int = a + b
fun sub(a: Int, b: Int): Int = a - b
}
\ No newline at end of file
...@@ -30,4 +30,5 @@ dependencyResolutionManagement { ...@@ -30,4 +30,5 @@ dependencyResolutionManagement {
} }
} }
include(":composeApp") include(":composeApp")
\ No newline at end of file include(":lib-arith")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment