Hongmeng 3.0 application development experience

Since the release of Hongmeng os3.0, Huawei has officially started to promote the ets+arkui development model, and gradually abandoned java to pave the way for the future de-Androidization. !

insert image description here

What is ets? ts is a superset of js, and ets is a superset of ts! The ability of Hongmeng SDKapi can be used in the file with ets suffix, it's that simple! And arkui is similar to Flutter and SwiftUI, it is a declarative development framework! And Google also launched the Jetpack Compose declarative development mode for native Android before. Is the declarative development mode of the mobile terminal the future trend?

@Entry
@Preview
@Component
struct main {
    
    
	 build(){
    
    
	     Column() {
    
    
	            Text("Hello World").fontSize(17).fontColor("#FFFFFF")
	          }
	          .alignItems(HorizontalAlign.Start)
	          .justifyContent(FlexAlign.Center)
	          .height('100%')
	          .height('100%')
	         }
}

@Entry is the page entry
@Preview means that the page can be previewed in real time
@Component fixed writing means that this is a component

For a more detailed explanation, you can directly go to the official website of Huawei Hongmeng OS to view the official documents. It is very clear, including components, layout, network requests, state management, data storage, media, etc.!

official document

At present, the api has been released to version 9:
insert image description here
through the sdk, we can find that the version above 8 no longer supports java, only supports js and arkts (ets), so when you create a project, if you choose api8+, then only It can be developed with ets. In addition, if you choose api8+, the developed Hongmeng app can only be installed on systems above 3.0, and is not compatible with Hongmeng 2.0! The change between api9 and api8 is that only the FA model is supported when api8 is selected, and the Stage model is added when api9 is selected!

API8:
insert image description here
API9:
insert image description here
And when choosing the Stage model, the development language only supports ArkTs. It seems that Hongmeng application development will fully use ArkTs in the future. The advantage of this is that it is compatible with the entire Hongmeng platform!

As for the difference between the FA and Stage models, I will briefly explain the differences here. I think the official documents will be clearer than what I have explained in detail!

FA model project structure:
insert image description here

  • config.json: configuration file (device information, pages, permissions, service cards, etc.);
  • app.ets: the entry file of MainAbility;
  • pages: pages;
  • resource: resource file;
  • Other folder names can be customized;

Here, Ability+app.ets belongs to the FA model. Of course, you can still create other Abilities under the ets folder:

insert image description here
Once created:

insert image description here

The page structure is the same as MainAbility, which is Ability+app.ts+pages structure, and the entry page of each Ability is also configured in config, and the first page defaults to the home page of the Ability (is it a bit similar to small program?):

insert image description here

Stage model project structure:

insert image description here

The configuration file of the Stage model is moudle.json5. You can also create other Abilities. The difference is that there is no app.ts. The home page of each Ability is not configured in moudle.json5, but directly set in Ability.ts:

insert image description here
Moreover, every time you create a page, you no longer need to configure the path in the configuration file to use it like the FA model, no configuration is required!

What they have in common is that they can create multiple abilities, and each ability can be set as the application startup entry:

insert image description here

These two icons are created by the same application. They belong to two Abilities. The premise is that you have configured startup entries for both Abilities. They are independent of each other and can jump to each other!

insert image description here

This function is still very good, it is equivalent to building n small applications in one application, haha...

Regarding Ability+pages, if you are an Android developer, you can actually understand it as Activity+Fragment. Of course, they are completely different things, but they can help you understand!

The author himself has recently redeveloped a company’s app Hongmeng version (simplified version, named: Accounting Coach Hongmeng version) using api8+FA+ArkTs. Those who are interested can download and experience it. Currently, it only supports systems above 3.0, and the 2.0 application market search less than), now available! The overall development experience is not bad, because I am familiar with Flutter and js development, so there is almost no difficulty in getting started with ArkTs. After reading the documentation, it is almost the same!

Disadvantages:
1. Some functional documents are not detailed enough;
2. When developers encounter problems, they can only go to the forum to ask questions, which is inefficient;
3. At present, there are few technical articles about Hongmeng development (all are some tutorials, few Technical articles on problems encountered in actual development);
4. ArkUI currently has few official components;
5. Some official components cannot meet actual needs, such as video does not support live broadcast, and the forum administrator replied that there is no support plan for the time being, just It's a bit unreasonable!
6. Signature configuration is too troublesome;
7. Ark does not seem to provide payment-related APIs, and access to Huawei payment seems to be troublesome;

I hope that Huawei Hongmeng official will continue to vigorously improve ark, and look forward to the day when Android is completely abandoned and Hongmeng rises!

(ps: If there are any inaccuracies in the article, please correct me!)

Guess you like

Origin blog.csdn.net/baiyuliang2013/article/details/128224334