You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调试Flutter应用时遭遇rive_common编译错误,求解决方案

Flutter编译错误:rive_common链接失败问题

依赖项

cupertino_icons: ^1.0.6
awesome_dialog: ^3.2.1
logger: ^2.2.0
provider: ^6.1.2
intl: ^0.19.0
bluetooth_print: ^4.3.0
flutter_svg: ^2.0.10+1
dropdown_button2: ^2.3.9
expansion_tile_card: ^3.0.0
pinput: ^4.0.0
shared_preferences: ^2.2.3
jwt_decoder: ^2.0.1
jumping_dot: ^0.0.6
rive_common: ^0.4.7
http: any

编译错误日志

PS C:\Users\HP\Downloads\test\flutter_application_1> flutter run          
Launching lib\main.dart on sdk gphone x86 in debug mode...
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':rive_common:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\rive_common-0.4.7\android\.cxx\Debug\p2o102m4\arm64-v8a'
  [1/1] Linking CXX shared library C:\Users\HP\Downloads\test\flutter_application_1\build\rive_common\intermediates\cxx\Debug\p2o102m4\obj\arm64-v8a\librive_text.so
  FAILED: C:/Users/HP/Downloads/test/flutter_application_1/build/rive_common/intermediates/cxx/Debug/p2o102m4/obj/arm64-v8a/librive_text.so
  cmd.exe /C "cd . && C:\Users\HP\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android21 --sysroot=C:/Users/HP/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -DWITH_RIVE_TEXT -DWITH_RIVE_AUDIO_TOOLS -DWITH_RIVE_AUDIO -DMA_NO_RESOURCE_MANAGER -DHAVE_OT -DHB_NO_FALLBACK_SHAPE -DHB_NO_WIN1256 -DHB_NO_EXTERN_HELPERS -DHB_NO_CFF -DHB_NO_BUFFER_VERIFY -DHB_NO_BUFFER_MESSAGE -DHB_NO_PAINT -DHB_NO_MMAP -DHB_NO_META -DYOGA_EXPORT= -std=c++11 -fno-limit-debug-info  -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,librive_text.so -o C:\Users\HP\Downloads\test\flutter_application_1\build\rive_common\intermediates\cxx\Debug\p2o102m4\obj\arm64-v8a\librive_text.so @CMakeFiles\rive_text.rsp  && cd ."
  ld: error: undefined hidden symbol: OT::cff2::accelerator_t::get_extents(hb_font_t*, unsigned int, hb_glyph_extents_t*) const
  >>> referenced by hb-subset-plan.cc:1019 (C:/Users/HP/AppData/Local/Pub/Cache/hosted/pub.dev/rive_common-0.4.7/ios/harfbuzz/src/hb-subset-plan.cc:1019)
  >>>               CMakeFiles/rive_text.dir/C_/Users/HP/AppData/Local/Pub/Cache/hosted/pub.dev/rive_common-0.4.7/ios/harfbuzz/src/hb-subset-plan.cc.o:(_update_instance_metrics_map_from_cff2(hb_subset_plan_t*))
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

  C++ build system [build] failed while executing:
      @echo off
      "C:\\Users\\HP\\AppData\\Local\\Android\\sdk\\cmake\\3.18.1\\bin\\ninja.exe" ^
        -C ^
        "C:\\Users\\HP\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\rive_common-0.4.7\\android\\.cxx\\Debug\\p2o102m4\\arm64-v8a" ^
        rive_text
    from C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\rive_common-0.4.7\android

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 46s
Running Gradle task 'assembleDebug'...                             47.4s
Error: Gradle task assembleDebug failed with exit code 1
PS C:\Users\HP\Downloads\test\flutter_application_1> 

已尝试的解决步骤

  • 修改awesome_dialog和rive_common版本
  • 执行flutter clean操作

可行解决方案

方案1:升级rive_common到修复版本

将rive_common的版本升级到0.4.8或更高版本,该版本已修复Harfbuzz库的链接问题。修改pubspec.yaml后,执行:

flutter pub get
flutter clean
flutter run

方案2:降低NDK版本

如果暂时无法升级rive_common,可将Android NDK版本切换到24.x(如24.0.8215888):

  1. 打开Android Studio的SDK Manager
  2. 切换到SDK Tools标签,勾选"Show Package Details"
  3. 找到NDK (Side by side),选择24.x版本安装
  4. 在项目的android/local.properties文件中添加:
    ndkVersion=24.0.8215888
    
  5. 执行flutter clean后重新编译

方案3:禁用Rive文本功能(仅适用于未使用Rive文本的项目)

在项目的android/build.gradle中,为rive_common添加编译参数禁用文本支持:

subprojects {
    if (name.contains("rive_common")) {
        project.ext {
            withRiveText = false
        }
    }
}

之后执行flutter clean和flutter run


内容的提问来源于stack exchange,提问作者thisara_bodhithunga

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 09:00:57