一、问题描述
今天合并代码之后,编译的时候出现了下面的错误。
C:\CodeForAndroid\XTCWatch\XTCWatch\XTCWatch\p_babyinfo\build\intermediates\packaged_res\debug\layout\activity_talent_account_number.xml:9: AAPT: error: resource string/baby_talent_number (aka com.xtc.watch:string/baby_talent_number) not found.
C:\CodeForAndroid\XTCWatch\XTCWatch\XTCWatch\p_babyinfo\build\intermediates\packaged_res\debug\layout\activity_talent_account_number.xml:17: AAPT: error: resource string/baby_talent_number_tip (aka com.xtc.watch:string/baby_talent_number_tip) not found.
error: failed linking file resources.
Command: C:\Users\000\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\24e7e61be83dabe37ccdf37a941ea750\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
C:\Android\SDK\platforms\android-28\android.jar\
--manifest\
C:\CodeForAndroid\XTCWatch\XTCWatch\XTCWatch\watch\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
C:\CodeForAndroid\XTCWatch\XTCWatch\XTCWatch\watch\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@C:\CodeForAndroid\XTCWatch\XTCWatch\XTCWatch\watch\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
C:\CodeForAndroid\XTCWatch\XTCWatch\XTCWatch\watch\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--proguard-main-dex\
C:\CodeForAndroid\XTCWatch\XTCWatch\XTCWatch\watch\build\intermediates\legacy_multidex_aapt_derived_proguard_rules\debug\processDebugResources\manifest_keep.txt\
--custom-package\
com.xtc.watch\
-0\
apk\
--preferred-density\
xhdpi\
--output-text-symbols\
C:\CodeForAndroid\XTCWatch\XTCWatch\XTCWatch\watch\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
* 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 23s
但是我找到这个布局文件,去查看这两个字符串资源的时候,命名都是有对应的资源的,如下所示:
二、解决问题
明明有对应的资源,为什么会报错呢?
我一开始以为是没有clean干净导致的,clean了几次都还是报这个错。
2.1 原因
后来我发现,好像还是少了一个默认的资源。
2.2 解决问题
既然发现少了 默认的 values资源,把这个默认资源的字符串加上,即可。如下所示
扫描二维码关注公众号,回复:
9348208 查看本文章
再到布局文件看 Default资源
添加好了 Default资源之后,重新编译即可成功。
三、总结
当出现这个问题的时候,先看看有没有添加默认的字符串资源,如果没有添加的话,即使你添加了其他的语言的字符串资源,也是无法正常编译的!
作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:https://blog.csdn.net/qq446282412/article/details/90758755
☞ 本人QQ: 3024665621
☞ QQ交流群: 123133153
☞ github.com/ouyangpeng
☞ [email protected]