当前位置:   article > 正文

【我的Android进阶之旅】 解决Android编译出现问题:AAPT: error: resource string/xxx (aka xxx:string/xxx) not found._: aapt: error: resource string/setting_ptt (aka co

: aapt: error: resource string/setting_ptt (aka com.bmwgroup.apinext.china_s

一、问题描述

今天合并代码之后,编译的时候出现了下面的错误。
在这里插入图片描述

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

但是我找到这个布局文件,去查看这两个字符串资源的时候,命名都是有对应的资源的,如下所示:

在这里插入图片描述

在这里插入图片描述

二、解决问题

明明有对应的资源,为什么会报错呢?

我一开始以为是没有clean干净导致的,clean了几次都还是报这个错。

2.1 原因

后来我发现,好像还是少了一个默认的资源。

在这里插入图片描述

在这里插入图片描述

2.2 解决问题

既然发现少了 默认的 values资源,把这个默认资源的字符串加上,即可。如下所示

在这里插入图片描述

在这里插入图片描述
再到布局文件看 Default资源

在这里插入图片描述

在这里插入图片描述

添加好了 Default资源之后,重新编译即可成功。

在这里插入图片描述

三、总结

当出现这个问题的时候,先看看有没有添加默认的字符串资源,如果没有添加的话,即使你添加了其他的语言的字符串资源,也是无法正常编译的!


作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:https://blog.csdn.net/qq446282412/article/details/90758755
☞ 本人QQ: 3024665621
☞ QQ交流群: 123133153
☞ github.com/ouyangpeng
☞ oypcz@foxmail.com


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/313038
推荐阅读
相关标签
  

闽ICP备14008679号