天天看点

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

阅读本文大概需要 5 分钟。

最近华为鸿蒙OS 2.0正式开源!关于鸿蒙的教程其实网上也已经有一些尝鲜的小伙伴分享的相关文章了,编者我按照步骤一步步跑下来,整个流程还是非常简单的,尤其是对Android开发的小伙伴来说,从IDE到项目的创建及项目的编译安装简直是一模一样呀。我特么的都有点怀疑人生了...感兴趣的读者也可以试试哦。

再贴一下鸿蒙的源码地址:https://openharmony.gitee.com

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

咱们一起来跟着一位网友(一个俗人)学习一下如何跑起来第一个“hello world”,原文如下:

1.前序

https://www.harmonyos.com 网上搜索第一个不是官方是三方的

源码编译的下载: https://device.harmonyos.com/cn/ide 

开发应用的下载:https://developer.harmonyos.com/cn/develop/deveco-studio#download

https://device.harmonyos.com/cn/docs/start/get-code/oem_sourcecode_guide-0000001050769927

2. 开发应用部分

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验
用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

我把所有的SDK都按照上,打勾会自动下载。

2.2 创建的项目

点击创建项目,发现现在支持有三种类型

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验
用鸿蒙跑了个 “hello world”!鸿蒙开发初体验
用鸿蒙跑了个 “hello world”!鸿蒙开发初体验
用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

创建中:

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

下载gradle-5.4.1-all.zip慢得等等。( 默认下载到: 

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

这个应该有办法直接下载好

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

设置里面很全面都能进行设置,可以探索探索 ) grade 源已经正确的切换到华为国内

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验
用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

弹窗点击确认就可以下载了 (此处下载速度略慢,下载失败点击 downloadagain 继续下载 估计下载人太多,失败了十几次把)

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验
用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

刷新以后:

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

使用自己的华为账号登录(此处注意有坑,如果默认使用Chrome可能授权会失败,使用Windows自带的浏览器进行登录)

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

(开发者账号实名认证,我填写的是银行卡验证速度很快) 

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

进行授权:

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

授权成功:

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

同意协议:

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

罗列了可用的模拟器:

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

TV模拟器启动了

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

运行就可以看到模拟器了

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

运行成功:

用鸿蒙跑了个 “hello world”!鸿蒙开发初体验

以上就是对鸿蒙的初体验,体验下来,开发工具和Android studio的操作习惯区别不大,API和android系统略有差距。欢迎大家尝鲜。

继续阅读