Technology Sharing

How to modify the harmonas project to an openharmony project

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

At first, I couldn't tell the difference between harmonyos and openharmony, so I downloaded the development software directly from harmonyos. Later, I found something wrong.

First, you need to install the corresponding version of the development software. Hongmeng development is provided by two official websites, harmonyos and openharmony. Find the corresponding place to download the corresponding version of the development software. After everything is installed, you will find that your original project cannot run.

Next, in the project file build-profile.json5, paste the following code

  1. {
  2. "app": {
  3. "signingConfigs": [],
  4. "products": [
  5. {
  6. "name": "default",
  7. "signingConfig": "default",
  8. "compileSdkVersion": 10,
  9. "compatibleSdkVersion": 10,
  10. "runtimeOS": "OpenHarmony",
  11. }
  12. ],
  13. "buildModeSet": [
  14. {
  15. "name": "debug",
  16. },
  17. {
  18. "name": "release"
  19. }
  20. ]
  21. },
  22. "modules": [
  23. {
  24. "name": "entry",
  25. "srcPath": "./entry",
  26. "targets": [
  27. {
  28. "name": "default",
  29. "applyToProducts": [
  30. "default"
  31. ]
  32. }
  33. ]
  34. }
  35. ]
  36. }

2. Modify build-profile.json5 under the entry file to

  1. {
  2. "apiType": 'stageMode',
  3. "buildOption": {
  4. },
  5. "targets": [
  6. {
  7. "name": "default",
  8. "runtimeOS": "OpenHarmony"
  9. },
  10. {
  11. "name": "ohosTest",
  12. }
  13. ]
  14. }

3. Re-sign the device

4. Close the project, clear the project files, and reopen it

Finally, thank you ai