Android Studio Gradle编译时『No resource found that matches the given name』解决方法(windows系统的坑)...

本文探讨了在Windows环境下使用Gradle编译Android项目时遇到的问题,特别是当项目路径过长导致的编译错误。文中给出了两种解决方案:一是调整项目位置和名称;二是更换操作系统。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

* 最近帮团队同事配置gradle时,发现一个非常奇怪的问题:
> * 同样的gradle配置的项目,只是修改了一个项目的名称,竟然会出现以下奇怪问题:


## 现象
1. 一个编译完全OK,另外一个编译出现各种问题
2. mac上两个都能正常编译,windows上其中一个编译通不过

主要Error如下:

```
No resource found that matches the given name (at drawable with value @drawable/xxxxxxxxxxxxxxxxxxxxxxxx)
```
我们做了各种排除,最后发现问题的特点:
两个项目,一个可编译,一个编译失败,区别在于,文件路径不一样长,文件名不一样长,最后由这个想到了是不是这个原因了,mac没有类似限制……
不查不知道啊,一查吓一跳:


## 原因


> `windows限制路径字符长度最大值: 260……`[查看这是为何](http://stackoverflow.com/questions/1880321/why-does-the-260-character-path-length-limit-exist-in-windows)
因为gradle编译时引用 build目录下拉取的aar路径层次太深,超过260,编译时不通过,这就是为什么很同用windows的同学,会在配置完全OK的情况下编译失败.


## 解决方案:
1. 整个项目挪到根目录,项目文件名改短,暂时解决这个问题
2. 换用Linux系统 或者Mac电脑


## 结束语

windows真是坑啊,这个问题和Android的65536现象极为相似啊!!!

 

转载于:https://www.cnblogs.com/renkangke/p/4646838.html

这是什么问题 Error:Execution failed for task ':app:processDebugResources'. > Failed to execute aapt Error:com.android.ide.common.process.ProcessException: Error while executing process E:\AndroidSDK\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I E:\AndroidSDK\platforms\android-26\android.jar -M \\?\E:\chapter02\Register\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S E:\chapter02\Register\app\build\intermediates\res\merged\debug -m -J \\?\E:\chapter02\Register\app\build\generated\source\r\debug -F E:\chapter02\Register\app\build\intermediates\res\debug\resources-debug.ap_ --custom-package com.example.dell.register02 -0 apk --output-text-symbols \\?\E:\chapter02\Register\app\build\intermediates\symbols\debug --no-version-vectors} Error:org.gradle.process.internal.ExecException: Process 'command 'E:\AndroidSDK\build-tools\26.0.2\aapt.exe'' finished with non-zero exit value 1 Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process E:\AndroidSDK\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I E:\AndroidSDK\platforms\android-26\android.jar -M \\?\E:\chapter02\Register\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S E:\chapter02\Register\app\build\intermediates\res\merged\debug -m -J \\?\E:\chapter02\Register\app\build\generated\source\r\debug -F E:\chapter02\Register\app\build\intermediates\res\debug\resources-debug.ap_ --custom-package com.example.dell.register02 -0 apk --output-text-symbols \\?\E:\chapter02\Register\app\build\intermediates\symbols\debug --no-version-vectors} Error:(165, 31) No resource found that matches the given name (at 'layout_above' with value '@id/btn_submit'). Error:(165, 31) No resource found that matches the given name (at 'layout_above' with value '@id/btn_submit'). E:\chapter02\Register\app\build\intermediates\res\merged\debug\layout\activity_main.xml E:\chapter02\Register\app\src\main\res\layou
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值