ArkUI-X简介
ArkUI-X进一步将ArkUI扩展到了多个OS平台:目前支持OpenHarmony、HarmonyOS、Android、 iOS,后续会逐步增加更多平台支持。开发者基于一套主代码,就可以构建支持多平台的精美、高性能应用
该框架对应的IDE版本为 4.0 Beta2 ,相较于3.x版本而言,4.x版本支持了对多端OS的支持
ArkUI-X: ArkUI-X扩展ArkUI开发框架到多个OS平台, 让开发者基于一套主代码, 就可以构建支持多平台的精美、高性能应用。The ArkUI-X project extends the ArkUI framework to multiple OS platforms. This enables developers to use one main set of code to develop applications for multiple OS platforms.
DevEco Studio 简介
DevEco Studio 简介是华为官网推出的开发工具
下载 DevEco Studio 4.0 Beta2版本
ACE Tools简介
ACE Tools是一套为ArkUI-X应用开发者提供的命令行工具,支持在Windows/Ubuntu/macOS平台运行,用于构建OpenHarmony、HarmonyOS、Android和iOS平台的应用程序, 其功能包括开发环境检查,新建项目,编译打包,安装调试等。
安装 ACE Tools
进入ArkUI-X目录
npm install 安装ACE Tools
ace check检查环境(如果你开发过flutter的话,那么ace check就相当于flutter doctor)
翻译如下:
警告:
需要OpenHarmony sdk,请参考HarmonyOS开发人员下载并安装。
需要HarmonyOS Sdk,请参阅HarmonyOSDeveloper下载并安装它。
节点是必需的,请下载v14.19.1和v16之间的版本。
Ohpm是必需的,请使用DevEco Studio或命令行工具下载。
需要ArkUI-X Sdk,请下载最新版本。
需要安卓Sdk,请使用安卓工作室下载。
Android Studio是必需的,请访问https://developer.android.google.cn/studio下载它。
ace create project 可见需要将未配置的环境变量配置上去
[X] ArkUI-X(v1.0.0 Alpha)
X ArkUI-X SDK未安装
找不到X Node.js运行时环境
•Java Sdk,位于C:\Program Files\Java\jdk-21\
找不到X Ohpm工具
[X] OpenHarmony工具链-为OpenHarmoney设备开发
X OpenHarmony SDK未安装
找不到X Node.js运行时环境
•Java Sdk,位于C:\Program Files\Java\jdk-21\
找不到X Ohpm工具
[X] HarmonyOS工具链-为HarmonyOS设备开发
未安装X HarmonyOS SDK
找不到X Node.js运行时环境
•Java Sdk,位于C:\Program Files\Java\jdk-21\
找不到X Ohpm工具
[!]Android工具链-为Android设备开发
!如果您想开发Android APP,则未安装Android SDK
[√]DevEco Studio[需要DevEco Studio4.0 Beta2,API版本10+]
•DevEco Studio,位于C:\Program Files\Huawei\DevEco Studio\bin
[!]安卓工作室
!未安装Android Studio,您可以在中安装https://developer.android.google.cn/studio
配置nodejs环境
cmd 激活代码立即生效
set NODE_HOME=/path-to-nodejs-sdk
set PATH=%PATH%;%NODE_HOME%/bin
C:\Users\Administrator\node\node-16.20.1
nodejs附加目录配置
C:\Users\Administrator\node\node-16.20.1\node_modules\npm\bin
C:\Users\Administrator\node\node-16.20.1\node_modules
配置ohpm环境
C:\Users\Administrator\ohpm\ohpm-1.2.4\bin
配置Java环境
C:\Program Files\Java\jdk-21\
%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin
配置OpenHarmony SDK环境
OpenHarmony_HOME C:\Users\Administrator\AppData\Local\OpenHarmony\Sdk
%OpenHarmony_HOME%\versioncode\toolchains
配置HarmonyOS SDK环境
C:\Users\Administrator\AppData\Local\Huawei\Sdk
HarmonyOS_HOME C:\Users\Administrator\AppData\Local\Huawei\Sdk
%HarmonyOS_HOME%\hmscore\versioncode\toolchains
配置ArkUI-X SDK环境
C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk
ARKUIX_SDK_HOME C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk
C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk
%ARKUIX_SDK_HOME%
%ARKUIX_SDK_HOME%\10\arkui-x\toolchains\ace_tools\src\bin
配置Android studio SDK环境
C:\Users\Administrator\AppData\Local\Android\Sdk
ANDROID_HOME C:\Users\Administrator\AppData\Local\Android\Sdk
%ANDROID_HOME%\tools
%ANDROID_HOME%\tools\bin
%ANDROID_HOME%\build-tools\34.0.0
%ANDROID_HOME%\platform-tools
如果cmd 运行 ace check有没对的选项,可能是环境变量缓存的问题,请使用如下代码进行激活更新一下缓存
set NODE_HOME=/path-to-nodejs-sdk
set PATH=%PATH%;%NODE_HOME%/bin
ace create
让后我们将项目导入到华为DevEco Studio 就可以愉快的编写Arkts代码了
写点东西吧:
@State message: string = 'Hello Arkui-X'
菜单栏 Build > Build Hap(s)/APP(s) > Build APP(s) 构建为Android APP
遇到问题:gradle报错:Deprecated Gradle features were used in this build, making it incompatible with Gradle 8
开发工具:idea
gradle版本:7.5
JDK:17
问题:在初次导入工程之后,设置后项目的jdk相关版本之后,启动项目报错:Deprecated Gradle features were used in this build, making it incompatible with Gradle 8
排查点一:查看版本
查看当前环境的gradle版本是否有冲突
排查点二:查看是否有弃用语法
在idea的 Terminal 窗口 cd 到项目文件夹下,执行命令 ./gradlew --warning-mode all ,会看到下图的提示信息
笔者解决的
这是因为仓库的 jcenter() 语法被弃用,需要改用 mavenCentral() ,改完之后重新刷新项目即可
使用Android Studio打开你在DevEco Studio 中开发的基于ArkUI-X开发的项目
检查
使用华为官方推荐的 AnLink安联工具投屏到手机上查看最终效果 !!!
补充:关于ace run 暂时无法构建出APP到手机上 ,应该是官方BUG待修复
官方的nodejs配置完环境变量有缓存问题需要使用 (ctrf+f搜索激活代码进行激活)BUG待修复
以下是遇到的问题带修复 cmd 执行操作演示如下:
C:\Users\Administrator\Desktop\androidDemo>ace check [√] ArkUI-X(v1.0.0 Alpha) • ArkUI-X SDK at C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk • Node.js Runtime Environment at /path-to-nodejs-sdk • Java Sdk at C:\Program Files\Java\jdk-21\ • Ohpm at C:\Users\Administrator\ohpm [√] OpenHarmony toolchains - develop for OpenHarmony devices • OpenHarmony SDK at C:\Users\Administrator\AppData\Local\OpenHarmony\Sdk • Node.js Runtime Environment at /path-to-nodejs-sdk • Java Sdk at C:\Program Files\Java\jdk-21\ • Ohpm at C:\Users\Administrator\ohpm [√] HarmonyOS toolchains - develop for HarmonyOS devices • HarmonyOS SDK at C:\Users\Administrator\AppData\Local\Huawei\Sdk • Node.js Runtime Environment at /path-to-nodejs-sdk • Java Sdk at C:\Program Files\Java\jdk-21\ • Ohpm at C:\Users\Administrator\ohpm [√] Android toolchains - develop for Android devices • Android SDK at C:\Users\Administrator\AppData\Local\Android\Sdk [√] DevEco Studio [Requires DevEco Studio 4.0 Beta2, API Version 10+] • DevEco Studio at C:\Program Files\Huawei\DevEco Studio [!] Android Studio ! Android Studio is not installed, you can install in https://developer.android.google.cn/studio Warning: Android Studio is required, visit https://developer.android.google.cn/studio to download it. Tools info :[√] OpenHarmony hdc installed [√] HarmonyOS hdc installed [√] adb installed [√] Connected device (2 available) • Android Devices 3418645238000CF device • OpenHarmony/HarmonyOS Devices 3418645238000CF device ! ACE Tools found issues in 1 category. C:\Users\Administrator\Desktop\androidDemo>ace run Error: more than one devices/emulators found, please use '--device'. C:\Users\Administrator\Desktop\androidDemo>ace Usage: ace [options] Options: -V, --version output the version number -d, --device input device id to specify the device to do something -h, --help display help for command Commands: create [subcommand] create ace project/module/component/ability check check sdk environment devices list the connected devices. config [options] --openharmony-sdk [OpenHarmony SDK] --harmonyos-sdk [HarmonyOS SDK] --android-sdk [Android Sdk] --deveco-studio-path [DevEco Studio Path] --android-studio-path [Android Studio Path] --build-dir [Build Dir] --nodejs-dir [Nodejs Dir] --java-sdk [Java Sdk] --arkui-x-sdk [ArkUI-X SDK] --ohpm-dir [Ohpm Dir] build [options] [fileType] build hap/apk/app/aar/framework/xcframework of moduleName install [options] [fileType] install hap/apk/app on device uninstall [options] [fileType] uninstall hap/apk/app on device run [options] [fileType] run hap/apk on device launch [options] [fileType] launch hap/apk on device log [fileType] show debug log clean clean project test [options] [fileType] test apk/app on device --b [Test BundleName] --m [Test ModuleName] --unittest [TestRunner] --timeout [Test timeout] help [command] display help for command C:\Users\Administrator\Desktop\androidDemo>ace devices Tools info :[√] OpenHarmony hdc installed [√] HarmonyOS hdc installed [√] adb installed [√] Connected device (2 available) • Android Devices 3418645238000CF device • OpenHarmony/HarmonyOS Devices 3418645238000CF device C:\Users\Administrator\Desktop\androidDemo>ace --device 3418645238000CF Usage: ace [options] Options: -V, --version output the version number -d, --device input device id to specify the device to do something -h, --help display help for command Commands: create [subcommand] create ace project/module/component/ability check check sdk environment devices list the connected devices. config [options] --openharmony-sdk [OpenHarmony SDK] --harmonyos-sdk [HarmonyOS SDK] --android-sdk [Android Sdk] --deveco-studio-path [DevEco Studio Path] --android-studio-path [Android Studio Path] --build-dir [Build Dir] --nodejs-dir [Nodejs Dir] --java-sdk [Java Sdk] --arkui-x-sdk [ArkUI-X SDK] --ohpm-dir [Ohpm Dir] build [options] [fileType] build hap/apk/app/aar/framework/xcframework of moduleName install [options] [fileType] install hap/apk/app on device uninstall [options] [fileType] uninstall hap/apk/app on device run [options] [fileType] run hap/apk on device launch [options] [fileType] launch hap/apk on device log [fileType] show debug log clean clean project test [options] [fileType] test apk/app on device --b [Test BundleName] --m [Test ModuleName] --unittest [TestRunner] --timeout [Test timeout] help [command] display help for command C:\Users\Administrator\Desktop\androidDemo>ace run --device 3418645238000CF Start building hap... 系统找不到指定的路径。 Run tasks failed. Error: Command failed: cd C:\Users\Administrator\Desktop\androidDemo && C:\Users\Administrator\ohpm\bin\ohpm install && .\hvigorw -p product=default --mode module -p module=entry assembleHap at checkExecSyncError (node:child_process:861:11) at execSync (node:child_process:932:15) at runGradle (C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk\10\arkui-x\toolchains\ace_tools\src\ace-build\ace-compiler\index.js:246:5) at compilerPackage (C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk\10\arkui-x\toolchains\ace_tools\src\ace-build\ace-compiler\index.js:298:8) at compiler (C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk\10\arkui-x\toolchains\ace_tools\src\ace-build\ace-compiler\index.js:364:10) at run (C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk\10\arkui-x\toolchains\ace_tools\src\ace-run\index.js:32:5) at Command. (C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk\10\arkui-x\toolchains\ace_tools\src\bin\ace_tools.js:290:9) at Command.listener [as _actionHandler] (C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk\10\arkui-x\toolchains\ace_tools\node_modules\commander\lib\command.js:482:17) at C:\Users\Administrator\AppData\Local\ArkUI-X\Sdk\10\arkui-x\toolchains\ace_tools\node_modules\commander\lib\command.js:1283:65 { status: 1, signal: null, output: [ null, null, null ], pid: 20940, stdout: null, stderr: null } Compile failed. WARN: Before installing the [entry] hap,please complete the signature. There is no file to install Run failed. C:\Users\Administrator\Desktop\androidDemo>
本章完!如果你遇到了什么问题可以联系笔者(QQ 1842810327 ),一起学习,共同进步,文章整理不易,一键三连哦亲,关注,点赞加转发!
猜你喜欢
网友评论
- 搜索
- 最新文章
- 热门文章