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配置:
- 打开
android/build.gradle,确保Gradle插件版本与Gradle wrapper版本匹配(比如插件用7.4.2,wrapper对应7.5); - 检查
local.properties中的ndk.dir和cmake.dir路径是否正确,且无特殊字符。
- 打开
- 启用旧版native库打包方式:在
android/app/build.gradle的android代码块中添加以下配置,绕过路径解析问题:packagingOptions { jniLibs { useLegacyPackaging = true } } - 排查依赖冲突:移除最近添加的第三方依赖,逐步测试是否是依赖中的native库导致的解析错误。
内容的提问来源于stack exchange,提问作者Krazy Rapid Boots
相关产品推荐
相关产品推荐

