- Developing HarmonyOS Application as Android Developer
- Add HMS to support your android application in Huawei devices
- Background
- “Brand New” Operating System
- Harmony OS Development Pitfalls Guide — source download and compile
- Prepare the environment
- Hardware environment
- Software environment
- Download the source code
- Configure the repo tool
- Download the Harmony OS source code
- Configure the environment
- Install the file system packaging tool
- Download and configure the compilation tool chain
- Install the PYTHon3.8 and PIP package managers
- Prepare virtualenv
- Compile the source code
- Compile the command for the 3516 target platform
- Compile the command for the target platform 3518
- The command to compile the 3861 target platform
- Ffmpeg related compilation failure problem locating
- Refer to the link
- HarmonyOS 3.0.0 Developer Preview
- HarmonyOS 3.0 Release
- eTS
- ArkUI
- ArkCompiler
Developing HarmonyOS Application as Android Developer
Add HMS to support your android application in Huawei devices
Background
As of 2019, new Huawei devices are banned from using Google services. This ban means that Huawei devices can no longer access API provided by Google like Maps API, or using Firebase as platform for developing Huawei Devices.
This doesn’t mean Huawei can no longer manufacture devices with Android Operating System because Android itself is open-source. But a year later, Huawei announced that they are releasing a new operating system called HarmonyOS for Huawei devices.
What does that mean for us as Android Developer? Do we have to support new operating system? Or how do we maintain our android application to support HarmonyOS?
Let’s learn more about it together!
“Brand New” Operating System
It’s safe to presume that Huawei will no longer releasing new mobile device with Android because they have their own operating system now. But developing a new operating system is hard, how do they able to do that in one year?
Well, the easy answer is they don’t… But kinda is. So far as I can tell, it really looks like HarmonyOs is forked version of Android. HarmonyOS is built on top of AOSP (Android Open Source Project), so it have some similarities with Android OS. My company sent me HarmonyOS device to test, so I just run simple Android program on it and it works.
Because HarmonyOS works the same as Android and basically other operating system based on AOSP. All your UI/Presentation code will work as intended in HarmonyOS devices. Things like View configuration, or Activity and Fragment , you can still use all of that.
Knowing that, my goal is supporting my already-released Android Application for HarmonyOS with little modification as possible. Which basically mean, no creating new project or repo or branch (in git) for HarmonyOS, no downloading new software if possible.
Speaking of downloading new software, Huawei have their own IDE for developing HarmonyOS apps called HUAWEI DevEco Studio. But I’m not going to install it, but if you do… You can download it here:
Harmony OS Development Pitfalls Guide — source download and compile
This article describes how to download the Hongman System source code, how to configure a compilation environment that can compile three target platforms (Hi3516, Hi3518, and Hi3861) at one time, and how to compile the source code into binaries for all three target platforms.
Summary of pit points:
- Download the source code is basically not too much pit, can be very smooth
- One major pitfall in compiling the source code is that the default version of Scons relies on Python 3.7+, and the hung Python Base compilation relies on Python3. You need to install Python 3.7+ and work with python2.7/ Python3.6 on your current system! There are generally two solutions:
- Use virtualenv to manage multiple versions of Python. The advantage of this approach is that it only takes effect in the current shell session and does not affect the system environment, other users, and other shell sessions. The downside is that it requires a slightly more cumbersome Source active script before it can be used.
- Use the update-alternatives management system’s multiple versions of Python command. This approach requires switching the system’s link between /usr/bin/python and /usr/bin/python3. It may affect the normal use of Python-dependent applications such as APT, other users, and other shell sessions;
Prepare the environment
This section describes the software and hardware environment required to download, compile, and write the Hongmeng System.
Hardware environment
Among them, The Linux host is used for source download and compilation, and the Windows host is used for writing programs to boards and source editing.
Software environment
hardware | instructions |
---|---|
Linux host | It is recommended to install a physical machine, Ubuntu16.04 or above 64-bit system, Shell using bash, using a virtual machine can also be used, how to do not do detailed introduction here. |
Windows host | Windows XP/Windows 7 / Windows 10 system |
A remote terminal | MobaXterm (PuTTY, SecureCRT, and other remote terminals can also be used) can be used to log in to a Linux host from a Windows host to download and compile the source code |
USB to serial port chip driver | Download link:www.hihope.org/downloadPage, USB-to-serial Comm Port.exe file (the PL2302 chip is integrated into the USB Serial cable that comes with the AI Camera and DIY IPC kit, which requires this driver to be installed for identification). The CH340G chip is integrated on the WiFi IoT master chip. You can choose to automatically install drivers on the Internet. |
Download the source code
This section describes how to download the Hongmeng source code on a Linux host. All commands are executed on a Linux host through a remote terminal.
The «get from repository» method is used here, which makes it easy to update the code later. You can also download the source code from the official website (not covered here).
Configure the repo tool
If you don’t already have the repo command configured on your Linux system, you need to download and configure the repo command line tool:
Mkdir ~/bin/ # sudo apt install curl//gitee.com/oschina/repo/raw/fork_flow/repo-py3 ~/bin/repo chmod +x ~/bin/repo echo 'export PATH=~/bin:$PATH' ~/.bashrc source ~/.bashrc Copy the code
Download the Harmony OS source code
mkdir -p ~/harmonyos/openharmony cd ~/harmonyos/openharmony mkdir -p ~/harmonyos/openharmony cd ~/harmonyos/openharmony sudo apt install git Python # repo 'name' and 'user.email' need to be configured to start, if not, use the following command: # git config --global user.name"yourname" # git config --global user.email "your-email-address" repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verifyRepo sync -c # synchronizes changes to the remote repository every dayCopy the code
Configure the environment
This section describes how to configure the Hongmeng source build environment on a Linux host. All commands are executed on the Linux host through a remote terminal.
Install the file system packaging tool
- Run «mkfs.vfat». If the command is not found, install it
- Run «McOpy». If the command is not found, install it
Sudo apt-get install zip # sudo apt-get install dosfstools mtools #Copy the code
Download and configure the compilation tool chain
Run the following command to download the GN, Ninja, LLVM, and HC-Gen packages, and modify them according to the official documents. You do not need to copy and paste them repeatedly.
Compile the toolchain wget $URL_PREFIX/gcc_riscv32/7.3. 0/linux/gcc_riscv32-linux-7.3. 0Gz # Decompress gn/ninja/LLVM/hc-gen: tar -c ~/ -xvf gn1523..tar tar -C ~/ -xvf ninja1.9.. 0.tar tar -C ~/ -xvf llvm-linux-9.0. 0-34042.tar tar -C ~/ -xvf hc-gen-0.65-linux.tar tar -C ~/ -xvf gcc_riscv32-linux-7.3. 0Gz # Add gn/ninja/LLVM/hc-gen to ~/.bashrc: cat EOF ~/.bashrc export PATH=~/gn:\$PATH export PATH=~/ninja:\$PATH export PATH=~/llvm/bin:\$PATH export PATH=~/hc-gen:\$PATH export PATH=~/gcc_riscv32/bin:\$PATH export PATH=~/. Local /bin:\$PATH # User PIP binary tool directory EOF # environment variable source ~/.bashrcCopy the code
Install the PYTHon3.8 and PIP package managers
- Install PYTHon3.8 and PIP (sCONS is required for compiling the Hi3861 target platform, the default scons version requires python version =3.7) : Sudo apt-get install python3.8 python3-pip, python3 is 3.6, python3 is 3.6, python3 is 3.7+, sudo apt-get install python3.8 python3-pip, python3 is 3.6, python3 is 3.6, python3 is 3.7+
- Using virtualenv management, source the corresponding active script to switch the default Python version of the current shell session (recommended, the following are done in this way);
- Use update-alternatives management and switch the global Python script configuration (not recommended, you need to switch back after using, otherwise it will affect the use of apt and other python3-dependent packages);
- Configure PIP package download source to accelerate domestic PIP package installation:
mkdir ~/.pip/cat EOF ~/.pip/pip.conf [global] index-url = https://mirrors.huaweicloud.com/repository/pypi/simple trusted-host = mirrors.huaweicloud.com timeout = 120 EOF Copy the code
Prepare virtualenv
Pip3 install vritualenv create using PYTHon38.Virtualenv mkdir ~/ Harmonyos /venv virtualenv -p python3 for the default Python interpreter8.~/ Harmonyos /venv # Activate VirtualEnv, After activation of pip3 install will pack file cache to the corresponding subdirectory source ~ / harmonyos venv/bin/activate # install setuptools and kconfiglib pip3 install Setuptools kconfiglib # install pip3 install scons ecdsa PyCryptodome pip3 install --upgrade --ignore-installed six Add the activation script to bashrc, and the python virtual environment will be automatically activated on the next login. Can be used to deactivate the virtual environment is invalid cat EOF ~ /. Bashrc source ~ / harmonyos venv/bin/activate EOFCopy the code
Compile the source code
After activating the Python virtual environment you just created, run the following command in the source root directory (openHarmony directory) :
$source ~ / harmonyos venv/bin/activate # activate the virtual environment, activate deactivate command can make the virtual environment is invalid after $python build. Py - h the usage: python build.py ipcamera_hi3516dv300 python build.py ipcamera_hi3518ev300 python build.py wifiiot Quickstart: https://device.harmonyos.com/cn/docs/start/introduce/oem_start_guide-0000001054913231 positional arguments: product Name of the product optional arguments: -h, --help show this help message and exit -b BUILD_TYPE, --build_type BUILD_TYPE release or debug version. -t [TEST [TEST . ]], --test [TEST [TEST . ]] Compile test suit -n, --ndk Compile ndk Copy the code
You can see which target platforms are supported, and there are currently three available.
Compile the command for the 3516 target platform
python build.py ipcamera_hi3516dv300 -b debug Copy the code
The generated kernel, rootfs and userfs image files will be generated in the out/ ipcamera_hi3516DV300 directory. The U-boot binary is generated in the vendor directory. You can run the find vendor-name u-boot*.bin command to search for the binary.
Compile the command for the target platform 3518
python build.py ipcamera_hi3516dv300 -b debug Copy the code
The generated kernel, rootfs, and userfs image files will be generated in the out/ ipcamera_HI3518EV300 directory. The U-boot binary is generated in the vendor directory. You can run the find vendor-name u-boot*.bin command to search for the binary.
The command to compile the 3861 target platform
python build.py wifiiot Copy the code
The generated binary file is in the out/wifiiot/ subdirectory. You need to use the hi3861_Wifiiot_app_allinone. bin file.
Ffmpeg related compilation failure problem locating
Ffmpeg-related build failures may occur during compilation, possibly because of a problem with the configure process, Can through the vendor/hisi/hi35xx/middleware/source/third_party/ffmpeg/ffmpeg — y/ffbuild/config. See the log file.
Refer to the link
Hongmeng Equipment development: Device.Harmonyos.com/
Hongmeng App development: developer.harmonyos.com/
The original link: developer.huawei.com/consumer/cn.
HarmonyOS 3.0.0 Developer Preview
Up your application development game in JavaScript (JS) or extended TypeScript (eTS) with the enhanced SDK of API version 8. Thanks to the optimized ArkUI and ArkCompiler, you can spruce up the UI of your JS/eTS applications with sophisticated UI drawing features, and speed up the launch of your JS applications by 50%.
HarmonyOS 3.0 Release
Up your application development game in JavaScript (JS) or extended TypeScript (eTS) with the enhanced SDK of API version 8. Thanks to the optimized ArkUI and ArkCompiler, you can spruce up the UI of your JS/eTS applications with sophisticated UI drawing features, and speed up the launch of your JS applications by 50%.
eTS
Extended TypeScript (eTS) extends TypeScript by adding capabilities that work with the ArkUI framework, such as declarative UI and status management. With eTS, you will be able to develop high-performance applications in a simpler and more natural manner.
ArkUI
ArkUI is a declarative UI development framework for building HarmonyOS application UIs.
ArkCompiler
ArkCompiler is a unified programming platform developed by Huawei. Its key components include a compiler, toolchain, and runtime. By leveraging ArkCompiler, you’ll be able to compile and run high-level programming languages on the multi-chip platform, and create applications and services that can run on a wide range of different devices, from phones and laptops, to tablets, TVs and wearables.