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

Flutter Android项目运行失败:mergeDebugNativeLibs任务报错求助

Flutter Android端启动报错:app:mergeDebugNativeLibs的解决方案

报错信息:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Parameter format not correct -
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 ':app:mergeDebugNativeLibs'.
> Multiple build operations failed.
      Cannot parse result path string: 
      Cannot parse result path string: 
   > Cannot parse result path string: 
   > Cannot parse result path string: 

* 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 1m 17s
Running Gradle task 'assembleDebug'...                             79.4s
Exception: Gradle task assembleDebug failed with exit code 1

解决步骤:

  • 检查项目路径:确保项目所在路径没有中文、空格或特殊字符(如!@#$等),Windows系统下这类路径会导致Gradle解析失败,建议迁移到纯英文路径,例如D:\flutter_proj\my_app。
  • 清理重建项目:执行以下命令彻底清理缓存并重建:
    flutter clean
    flutter pub get
    # Windows系统执行
    cd android && gradlew.bat clean assembleDebug
    # Mac/Linux系统执行
    cd android && ./gradlew clean assembleDebug
    
  • 调整Gradle配置:
    1. 打开android/build.gradle,确保Gradle插件版本与Gradle wrapper版本匹配(比如插件用7.4.2,wrapper对应7.5);
    2. 检查local.properties中的ndk.dir和cmake.dir路径是否正确,且无特殊字符。
  • 启用旧版native库打包方式:在android/app/build.gradle的android代码块中添加以下配置,绕过路径解析问题:
    packagingOptions {
        jniLibs {
            useLegacyPackaging = true
        }
    }
    
  • 排查依赖冲突:移除最近添加的第三方依赖,逐步测试是否是依赖中的native库导致的解析错误。

内容的提问来源于stack exchange,提问作者Krazy Rapid Boots

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 16:51:07