Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TestToolChainDemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
dsq
TestToolChainDemo
Commits
bfebf9c4
Commit
bfebf9c4
authored
Feb 27, 2026
by
dsq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新kotlin版本
parent
220501f3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
62 deletions
+66
-62
build.gradle.kts
composeApp/build.gradle.kts
+36
-58
libs.versions.toml
gradle/libs.versions.toml
+2
-4
libkn.so
harmonyApp/entry/libs/arm64-v8a/libkn.so
+0
-0
libkn_api.h
harmonyApp/entry/src/main/cpp/include/libkn_api.h
+28
-0
No files found.
composeApp/build.gradle.kts
View file @
bfebf9c4
...
...
@@ -72,6 +72,12 @@ kotlin {
// 动态库 (isStatic = false) - 运行时加载的库
isStatic
=
true
// 设置framework为静态库
}
iosTarget
.
compilations
.
getByName
(
"main"
)
{
compilerOptions
.
configure
{
freeCompilerArgs
.
add
(
"-Xbinary=sanitizer=address"
)
freeCompilerArgs
.
add
(
"-Xbinary=splitBCfile=1"
)
}
}
}
// 配置OHOS(华为鸿蒙)arm64目标
...
...
@@ -81,19 +87,22 @@ kotlin {
export
(
libs
.
compose
.
multiplatform
.
export
)
// 导出compose多平台库的接口
}
val
main
by
compilations
.
getting
// 获取主编译内容
main
.
compilerOptions
.
configure
{
freeCompilerArgs
.
add
(
"-Xbinary=sanitizer=address"
)
freeCompilerArgs
.
add
(
"-Xbinary=splitBCfile=1"
)
}
val
resource
by
main
.
cinterops
.
creating
{
//配置C interop(cinterop)资源
defFile
(
file
(
"src/ohosArm64Main/cinterop/resource.def"
))
// cinterop定义文件
includeDirs
(
file
(
"src/ohosArm64Main/cinterop/include"
))
// cinterop包含目录
compilerOpts
(
"-fno-modules"
)
// 禁用模块以避免平台库依赖
}
}
// 配置各平台的依赖关系
sourceSets
{
androidMain
.
dependencies
{
implementation
(
libs
.
androidx
.
activity
.
compose
)
implementation
(
libs
.
androidx
.
collection
)
implementation
(
libs
.
androidx
.
lifecycle
.
viewmodelCompose
)
implementation
(
libs
.
androidx
.
lifecycle
.
runtimeCompose
)
}
...
...
@@ -107,21 +116,9 @@ kotlin {
implementation
(
libs
.
kotlinx
.
coroutines
.
core
)
// 官方协程核心库
implementation
(
libs
.
atomicFu
)
// Kotlin AtomicFu原子库
}
commonTest
.
dependencies
{
implementation
(
libs
.
kotlin
.
test
)
// 添加Kotlin通用测试依赖
}
val
ohosArm64Main
by
getting
{
dependencies
{
api
(
libs
.
compose
.
multiplatform
.
export
)
// 导出compose多平台接口给依赖消费者
// 添加OHOS平台特定依赖
implementation
(
"org.jetbrains.kotlin:kotlin-stdlib"
)
}
}
// iOS平台配置
iosMain
{
dependencies
{
implementation
(
libs
.
kotlinx
.
coroutines
.
core
)
// iOS也需要协程支持
}
}
}
...
...
@@ -138,11 +135,11 @@ Android 构建工具 → 打包成 APK
控制 APK 生成、打包、签名等
*/
android
{
namespace
=
"com.dong.
demo013
"
// 设置包名
namespace
=
"com.dong.
n4.n4test010
"
// 设置包名
compileSdk
=
libs
.
versions
.
android
.
compileSdk
.
get
().
toInt
()
// 指定编译SDK版本
defaultConfig
{
applicationId
=
"com.dong.
demo013
"
// 应用ID
applicationId
=
"com.dong.
n4.n4test010
"
// 应用ID
minSdk
=
libs
.
versions
.
android
.
minSdk
.
get
().
toInt
()
// 最低SDK版本
targetSdk
=
libs
.
versions
.
android
.
targetSdk
.
get
().
toInt
()
// 目标SDK版本
versionCode
=
1
// 应用版本号
...
...
@@ -168,47 +165,28 @@ dependencies {
debugImplementation
(
libs
.
compose
.
ui
.
tooling
)
// debug模式下依赖compose调试工具
}
compose
{
ohos
{
skia
(
"0.9.22.2-ez-001"
)
// ohrender(" 0.9.22.2-ohrende")
}
}
// 为 ohosArm64 目标配置依赖处理
val
versionCatalog
=
extensions
.
getByType
<
VersionCatalogsExtension
>().
named
(
"libs"
)
val
cmpVersion
=
versionCatalog
.
findVersion
(
"composeMultiplatform"
)
.
orElseThrow
{
IllegalStateException
(
"Missing version composeMultiplatform in version catalog"
)
}
.
requiredVersion
val
skikoOverrideByCmpVersion
=
mapOf
(
"1.9.2-ez-001"
to
"0.9.22.2-ez-001"
,
// 仅在需要强制的 CMP 版本这里新增
)
val
skikoOhosOverride
=
skikoOverrideByCmpVersion
[
cmpVersion
]
configurations
.
all
{
val
configName
=
name
if
(
configName
.
contains
(
"ohos"
,
ignoreCase
=
true
))
{
incoming
.
afterResolve
{
val
resolvedSkiko
=
resolutionResult
.
allComponents
.
mapNotNull
{
it
.
moduleVersion
}
.
firstOrNull
{
it
.
group
==
"org.jetbrains.skiko"
&&
it
.
name
==
"skiko"
}
logger
.
lifecycle
(
"Resolved skiko for $configName: "
+
(
resolvedSkiko
?.
let
{
"${it.group}:${it.name}:${it.version}"
}
?:
"not found"
)
)
}
// exclude(group = "org.jetbrains.androidx.lifecycle")
// exclude(group = "org.jetbrains.androidx.savedstate")
}
resolutionStrategy
{
eachDependency
{
// 如果是 skiko 依赖,检查配置名称是否包含 ohos
if
(
requested
.
group
==
"org.jetbrains.skiko"
&&
requested
.
name
==
"skiko"
)
{
if
(
configName
.
contains
(
"ohos"
,
ignoreCase
=
true
))
{
skikoOhosOverride
?.
let
{
useVersion
(
it
)
}
}
}
// 强制指定 androidx.collection 版本,避免冲突
if
(
requested
.
group
==
"androidx.collection"
&&
requested
.
name
==
"collection"
)
{
useVersion
(
libs
.
versions
.
androidx
.
collection
.
get
())
}
}
// TODO: 强制刷新 compose ui ohosarm64 依赖
force
(
"org.jetbrains.compose.export:export-ohosarm64:${cmpVersion}"
)
force
(
"org.jetbrains.compose.ui:ui-ohosarm64:${cmpVersion}"
)
force
(
"org.jetbrains.compose.ui:ui-arkui-ohosarm64:${cmpVersion}"
)
force
(
"org.jetbrains.compose.foundation:foundation-ohosarm64:${cmpVersion}"
)
}
exclude
(
group
=
"androidx.collection"
,
module
=
"collection-jvm"
)
}
// Harmony App 输出目录(支持命令行 --harmonyAppPath)
...
...
gradle/libs.versions.toml
View file @
bfebf9c4
...
...
@@ -11,11 +11,10 @@ androidx-espresso = "3.7.0"
androidx-lifecycle
=
"2.9.6"
androidx-material
=
"1.12.0"
androidx-testExt
=
"1.3.0"
androidx-collection
=
"1.4.5"
compose
=
"1.9.4"
composeMultiplatform
=
"1.9.2-
ez-0
01"
composeMultiplatform
=
"1.9.2-
OH.0.1.0-
01"
junit
=
"4.13.2"
kotlin
=
"2.2.21-
ez-0
01"
kotlin
=
"2.2.21-
OH.0.1.0-
01"
kotlinx-coroutines
=
"1.8.0-KBA-001"
atomicFu
=
"0.23.2-KBA-001"
...
...
@@ -30,7 +29,6 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a
androidx-activity-compose
=
{
module
=
"androidx.activity:activity-compose"
,
version.ref
=
"androidx-activity"
}
androidx-lifecycle-viewmodelCompose
=
{
module
=
"org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose"
,
version.ref
=
"androidx-lifecycle"
}
androidx-lifecycle-runtimeCompose
=
{
module
=
"org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose"
,
version.ref
=
"androidx-lifecycle"
}
androidx-collection
=
{
module
=
"androidx.collection:collection"
,
version.ref
=
"androidx-collection"
}
compose-multiplatform-export
=
{
module
=
"org.jetbrains.compose.export:export"
,
version.ref
=
"composeMultiplatform"
}
androidx-constraintlayout
=
{
group
=
"androidx.constraintlayout"
,
name
=
"constraintlayout"
,
version.ref
=
"androidx-constraintlayout"
}
androidx-material
=
{
group
=
"com.google.android.material"
,
name
=
"material"
,
version.ref
=
"androidx-material"
}
...
...
harmonyApp/entry/libs/arm64-v8a/libkn.so
View file @
bfebf9c4
No preview for this file type
harmonyApp/entry/src/main/cpp/include/libkn_api.h
View file @
bfebf9c4
...
...
@@ -126,6 +126,7 @@ typedef struct {
extern
void
*
MainArkUIViewController
(
void
*
env
);
extern
libkn_KInt
hiLogPrintMsg
(
libkn_KUInt
type
,
libkn_KUInt
level
,
libkn_KUInt
domain
,
const
char
*
tag
,
const
char
*
message
);
extern
libkn_KInt
kn_get_render_backend_id
();
extern
void
androidx_compose_ui_arkui_ArkUIViewController_aboutToAppear
(
void
*
controllerRef
);
extern
void
androidx_compose_ui_arkui_ArkUIViewController_aboutToDisappear
(
void
*
controllerRef
);
extern
void
androidx_compose_ui_arkui_ArkUIViewController_cancelSyncRefresh
(
void
*
controllerRef
,
libkn_KInt
refreshId
);
...
...
@@ -154,9 +155,16 @@ extern void androidx_compose_ui_arkui_ArkUIViewController_setContext(void* contr
extern
void
androidx_compose_ui_arkui_ArkUIViewController_setEnv
(
void
*
controllerRef
,
void
*
env
);
extern
void
androidx_compose_ui_arkui_ArkUIViewController_setId
(
void
*
controllerRef
,
const
char
*
id
);
extern
void
androidx_compose_ui_arkui_ArkUIViewController_setMessenger
(
void
*
controllerRef
,
void
*
messenger
);
extern
void
androidx_compose_ui_arkui_ArkUIViewController_setRenderBackendId
(
void
*
controllerRef
,
libkn_KInt
backendId
);
extern
void
androidx_compose_ui_arkui_ArkUIViewController_setRootView
(
void
*
controllerRef
,
void
*
backRootView
,
void
*
foreRootView
,
void
*
touchableRootView
);
extern
void
androidx_compose_ui_arkui_ArkUIViewController_setUIContext
(
void
*
controllerRef
,
void
*
uiContext
);
extern
void
androidx_compose_ui_arkui_ArkUIViewController_setXComponentRender
(
void
*
controllerRef
,
void
*
render
);
extern
void
buildInstance
(
void
*
env
,
void
*
func
);
extern
void
*
createRootRenderNode
();
extern
void
renderNodeDraw
(
void
*
env
,
void
*
jsCanvas
,
void
*
jsNode
);
extern
void
renderNodeNotifyRedraw
(
void
*
env
,
void
*
jsNode
);
extern
void
setNodeConstructor
(
void
*
env
,
void
*
func
);
extern
void
setPixelRatio
(
libkn_KDouble
ratio
);
extern
void
androidx_compose_ui_arkui_init
(
void
*
env
,
void
*
exports
);
typedef
struct
{
...
...
@@ -379,6 +387,18 @@ typedef struct {
struct
{
struct
{
struct
{
libkn_KInt
(
*
kn_get_render_backend_id_
)();
}
internal
;
}
ohos
;
}
compose
;
}
jetbrains
;
}
org
;
struct
{
struct
{
struct
{
struct
{
struct
{
void
*
(
*
get_NodeDrawCallback
)();
void
(
*
_Export_ArkUIViewController_aboutToAppear
)(
void
*
controllerRef
);
void
(
*
_Export_ArkUIViewController_aboutToDisappear
)(
void
*
controllerRef
);
void
(
*
_Export_ArkUIViewController_cancelSyncRefresh
)(
void
*
controllerRef
,
libkn_KInt
refreshId
);
...
...
@@ -407,9 +427,17 @@ typedef struct {
void
(
*
_Export_ArkUIViewController_setEnv
)(
void
*
controllerRef
,
void
*
env
);
void
(
*
_Export_ArkUIViewController_setId
)(
void
*
controllerRef
,
const
char
*
id
);
void
(
*
_Export_ArkUIViewController_setMessenger
)(
void
*
controllerRef
,
void
*
messenger
);
void
(
*
_Export_ArkUIViewController_setRenderBackendId
)(
void
*
controllerRef
,
libkn_KInt
backendId
);
void
(
*
_Export_ArkUIViewController_setRootView
)(
void
*
controllerRef
,
void
*
backRootView
,
void
*
foreRootView
,
void
*
touchableRootView
);
void
(
*
_Export_ArkUIViewController_setUIContext
)(
void
*
controllerRef
,
void
*
uiContext
);
void
(
*
_Export_ArkUIViewController_setXComponentRender
)(
void
*
controllerRef
,
void
*
render
);
void
(
*
buildInstance_
)(
void
*
env
,
void
*
func
);
void
*
(
*
createRootRenderNode_
)();
libkn_KLong
(
*
getCurrentTimeNanos
)();
void
(
*
renderNodeDraw_
)(
void
*
env
,
void
*
jsCanvas
,
void
*
jsNode
);
void
(
*
renderNodeNotifyRedraw_
)(
void
*
env
,
void
*
jsNode
);
void
(
*
setNodeConstructor_
)(
void
*
env
,
void
*
func
);
void
(
*
setPixelRatio_
)(
libkn_KDouble
ratio
);
void
(
*
_Export_ArkUIViewInitializer_init
)(
void
*
env
,
void
*
exports
);
}
arkui
;
}
ui
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment