今天突然遇到一个问题:
C:\Users\Hzx\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\cd25e25b1ef780c5b0d840e0ab03e27b\res\values-v26\values-v26.xml
Error:(13, 5) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
F:\Git\AkeetaApp-Android\app\build\intermediates\res\merged\debug\values-v26\values-v26.xml
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process C:\Users\Hzx\AppData\Local\Android\sdk1\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I C:\Users\Hzx\AppData\Local\Android\sdk1\platforms\android-25\android.jar -M \\?\F:\Git\AkeetaApp-Android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S F:\Git\AkeetaApp-Android\app\build\intermediates\res\merged\debug -m -J \\?\F:\Git\AkeetaApp-Android\app\build\generated\source\r\debug -F F:\Git\AkeetaApp-Android\app\build\intermediates\res\debug\resources-debug.ap_ -D \\?\F:\Git\AkeetaApp-Android\app\build\intermediates\multi-dex\debug\manifest_keep.txt --custom-package com.argrace.smart -0 apk --preferred-density xxhdpi --output-text-symbols \\?\F:\Git\AkeetaApp-Android\app\build\intermediates\symbols\debug --no-version-vectors}
Error:com.android.ide.common.process.ProcessException: Error while executing process C:\Users\Hzx\AppData\Local\Android\sdk1\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I C:\Users\Hzx\AppData\Local\Android\sdk1\platforms\android-25\android.jar -M \\?\F:\Git\AkeetaApp-Android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S F:\Git\AkeetaApp-Android\app\build\intermediates\res\merged\debug -m -J \\?\F:\Git\AkeetaApp-Android\app\build\generated\source\r\debug -F F:\Git\AkeetaApp-Android\app\build\intermediates\res\debug\resources-debug.ap_ -D \\?\F:\Git\AkeetaApp-Android\app\build\intermediates\multi-dex\debug\manifest_keep.txt --custom-package com.argrace.smart -0 apk --preferred-density xxhdpi --output-text-symbols \\?\F:\Git\AkeetaApp-Android\app\build\intermediates\symbols\debug --no-version-vectors}
Error:org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Hzx\AppData\Local\Android\sdk1\build-tools\26.0.2\aapt.exe'' finished with non-zero exit value 1
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
看到这个,一开始以为是包重复导致的,查了下External Libraries,发现很多v4,v7包,多了一个重复的。我build文件里,只添加了25版的,突然多了27版的,莫名其妙的多了。我查了我所有的lib,都没有发现有地方调用到27版的东西。非常奇怪。那这个27版的v7包是怎么导入到里面的呢。
原来程序里,有个这样的引用
implementation 'com.android.support.constraint:constraint-layout:+'
这个包应该是升级了,所以,它自动会引用最高版的,我此时它是升级到2.0.0版。我猜测,是2.0.0版的implementation 'com.android.support.constraint:constraint-layout:+'需要用到27版的v7包,所以自动给我程序导入了。
总结:
尽量不要使用“:+”来导入包,容易出错。
AAPT2error:checklogsfordetails解决方法
直接移步去看吧,http://blog.sina.com.cn/s/blog_5de73d0b0102yffd.html
大体是说,构建 App 的时候,打开 Build 窗口,点击 “Toggle View” 切换到文本输出。这里能看到错误的详细错误