DEV Community

flfljh
flfljh

Posted on

Flutter Environment Issues on HarmonyOS

Harmony OS Next

Flutter Environment Issues on HarmonyOS

Recommended Development Tool Versions

  • Flutter 3.7.12-ohos
  • Python 3.8 - 3.11
  • Java 17
  • Node 18
  • ohpm 1.6+
  • HarmonyOS SDK API 11
  • Xcode 14.3

flutter pub get Fails in Offline Environments

Solution: Use --offline flag:

flutter pub get --offline
Enter fullscreen mode Exit fullscreen mode

Release Build Failure on macOS

Error Log:

ProcessPackageException: ProcessException: Found candidates, but lacked sufficient permissions to execute "/Users/xxx/ohos/src/out/ohos_release_arm64/clang_arm4/dart".
Enter fullscreen mode Exit fullscreen mode

Solution: Add execute permissions:

chmod -R +x /Users/xxx/ohos/src/out/ohos_release_arm64/*
Enter fullscreen mode Exit fullscreen mode

Additional macOS Steps:

  1. Manually run dart and gen_snapshot in src/out/ohos_release_arm64/clang_arm64/
  2. Go to System Settings → Privacy & Security → Security
  3. Allow execution of these programs

Flutter Fails After Copying from Windows to Linux/macOS

Error Log:

curl: (3) Illegal characters found in URL
xxx/flutter_flutter/bin/internal/update_dart_sdk.sh: line 156: return: can only return from a function or sourced script
Enter fullscreen mode Exit fullscreen mode

Cause: CRLF (Windows) vs LF (Unix) line ending mismatch

Solution:

# Linux:
sed -i "s/\r//" bin/dart $(find bin -name "*.sh") $(find bin -name "*.version")

# macOS:
sed -i "" "s/\r//" bin/dart $(find bin -name "*.sh") $(find bin -name "*.version")
Enter fullscreen mode Exit fullscreen mode

~/.npmrc Configuration

registry=https://repo.huaweicloud.com/repository/npm/
@ohos:registry=https://repo.harmonyos.com/npm/
strict-ssl=false
# Proxy example:
# http_proxy=http://user:password@host:8080
# https_proxy=http://user:password@host:8080
Enter fullscreen mode Exit fullscreen mode

~/.ohpmrc Configuration

registry=https://repo.harmonyos.com/ohpm/
strict_ssl=false
# Proxy example:
# http_proxy=http://user:password@host:8080
# https_proxy=http://user:password@host:8080
Enter fullscreen mode Exit fullscreen mode

Emulator Crash with Default Counter App

Cause:

Solution: Comment out FloatingActionButton in lib/main.dart


iosGeneratedPluginRegistrant.m Module Not Found

Cause: New Flutter plugins added without updating Podfile

Solution:

rm ios/Podfile && flutter clean && flutter run -d <ios_device>
Enter fullscreen mode Exit fullscreen mode

Reference: GeneratedPluginRegistrant.m Module not found


flutter doctor -v Hangs on Windows

Symptoms: No response after environment setup

Cause: Proxy misconfiguration

Solution: Configure system environment variables:

HTTP_PROXY=http://your-proxy:port
HTTPS_PROXY=http://your-proxy:port  # Can match HTTP_PROXY
NO_PROXY=localhost,::1,127.0.0.1,additional-domains
Enter fullscreen mode Exit fullscreen mode

Successful Output: Shows both Flutter and HarmonyOS supporterror

Top comments (0)