HarmonyOS鸿蒙Next中fluttertpc_record编译报错

HarmonyOS鸿蒙Next中fluttertpc_record编译报错 flutter_ohos 3.22版本,开始编译在本机的鸿蒙模拟器时报错,有没有大佬看一下是什么问题,感觉这个record适配是不是有点问题

图片

(node:9596) [DEP0169] DeprecationWarning: url.parse() behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for url.parse() vulnerabilities.

(Use node --trace-deprecation ... to show where the warning was created)

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!

/D:/PubCache/hosted/pub.flutter-io.cn/record_linux-0.7.2/lib/record_linux.dart:12:7: Error: The non-abstract class ‘RecordLinux’ is missing implementations for these members:

  • RecordPlatform.startStream

Try to either

  • provide an implementation,

  • inherit an implementation from a superclass or mixin,

  • mark the class as abstract, or

  • provide a ‘noSuchMethod’ implementation.

class RecordLinux extends RecordPlatform {

  ^^^^^^^^^^^

/D:/PubCache/hosted/pub.flutter-io.cn/record_platform_interface-1.3.0/lib/src/record_platform_interface.dart:55:29: Context: ‘RecordPlatform.startStream’ is defined here.

Future<Stream<Uint8List>> startStream(

                        ^^^^^^^^^^^

Target kernel_snapshot failed: Exception

hvigor ERROR: Failed :entry:default@FlutterTask

hvigor ERROR: Command failed: D:\flutter-homeng\flutter_flutter\bin\flutter.bat --quiet assemble --no-version-check --depfile


更多关于HarmonyOS鸿蒙Next中fluttertpc_record编译报错的实战教程也可以访问 https://www.itying.com/category-92-b0.html

2 回复

在HarmonyOS Next中编译fluttertpc_record报错,可能涉及以下原因:Flutter SDK版本与HarmonyOS Next不兼容,或该插件未适配鸿蒙系统。检查Flutter插件是否支持HarmonyOS,并确保使用官方推荐的Flutter for HarmonyOS版本。更新依赖项至兼容版本,或尝试替换为鸿蒙原生音频录制API。

更多关于HarmonyOS鸿蒙Next中fluttertpc_record编译报错的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html


这个编译错误是因为 record_linux 包在 HarmonyOS Next 环境下缺少对 startStream 方法的实现。错误信息显示 RecordLinux 类继承自 RecordPlatform,但没有实现必需的 startStream 方法。

问题分析:

  • record_linux 包是针对 Linux 平台的录音实现,在 HarmonyOS Next 上无法直接兼容
  • 鸿蒙的音频流处理机制与 Linux 存在差异,导致平台接口适配不完整

解决方案:

  1. 检查是否使用了最新版本的 flutter_ohos 和相关录音插件
  2. 考虑使用专门为鸿蒙适配的录音插件替代 record_linux
  3. 如果必须使用当前插件,可能需要手动实现缺失的 startStream 方法
  4. 检查鸿蒙模拟器的音频权限配置

建议暂时移除 record_linux 依赖,测试其他录音方案在鸿蒙环境下的兼容性。

回到顶部