Flutter添加依赖后assembleDebug构建任务失败求助
最近给我的Flutter项目新增依赖后,执行assembleDebug构建任务直接失败了,翻了完整的报错日志,发现是两个核心问题,整理出来求社区大佬帮忙支招!
一、NDK版本不兼容问题
报错开头就明确指出了NDK版本不匹配的冲突:
Your project is configured with Android NDK
26.3.11579264, but the following plugin(s) depend on a different Android NDK version:
path_provider_androidrequires Android NDK27.0.12077973
Fix this issue by using the highest Android NDK version (they are backward compatible). Add the following toD:\New folder (2)\test_flutter\android\app\build.gradle.kts:
android { ndkVersion = "27.0.12077973" ... }
我已经准备按照提示去修改build.gradle.kts的配置了,但不确定改完这个就能解决所有问题,因为后面还有一堆资源编译的报错。
二、资源文件路径不存在导致编译失败
除了NDK的问题,还有大量资源编译失败的报错,核心都是系统找不到指定路径的资源文件,具体报错如下:
- What went wrong:
Execution failed for task:app:mergeDebugResources.Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
Resource compilation failed (D:\New folder (2)\test_flutter\build\app\intermediates\incremental\debug\mergeDebugResources\merged.dir\values\values.xml(The system cannot find the path specified). Cause: null). Check logs for more details.
A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
Resource compilation failed (D:\New folder (2)\test_flutter\build\app\intermediates\incremental\debug\mergeDebugResources\merged.dir\values-de\values-de.xml(The system cannot find the path specified). Cause: null). Check logs for more details.
A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
Resource compilation failed (D:\New folder (2)\test_flutter\build\app\intermediates\incremental\debug\mergeDebugResources\merged.dir\values-hi\values-hi.xml(The system cannot find the path specified). Cause: null). Check logs for more details.
A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
Resource compilation failed (D:\New folder (2)\test_flutter\build\app\intermediates\incremental\debug\mergeDebugResources\merged.dir\values-lo\values-lo.xml(The system cannot find the path specified). Cause: null). Check logs for more details.
我手动检查了build目录下的对应路径,确实找不到这些values子目录和对应的xml文件。目前猜测可能是构建中间文件损坏,或者是项目路径里的空格(比如New folder (2))导致的路径识别问题?
另外报错里给出的排查建议我也看了,但日志里没有更多细节:
- Try:
Run with
--stacktraceoption to get the stack trace.
Run with--infoor--debugoption to get more log output.
Run with--scanto get full insights.
有没有大佬遇到过类似的问题?先改NDK版本再清构建缓存有用吗?或者路径空格的问题是不是真的会导致这种情况?求指点!
内容来源于stack exchange




