ResourceType对于资源条目索引超出类型entryCount

has*_*ian 5 android android-studio android-studio-3.2

我用Android Studio 3.2。清理/重建项目时,我在build工具窗口中看到以下警告:

W/ResourceType( 6139): For resource 0x0101053d, entry index(1341) is beyond type entryCount(1155)
W/ResourceType( 6139): For resource 0x0101053e, entry index(1342) is beyond type entryCount(1155)
W/ResourceType( 6139): For resource 0x0101053b, entry index(1339) is beyond type entryCount(1155)
W/ResourceType( 6139): For resource 0x0101053c, entry index(1340) is beyond type entryCount(1155)
Run Code Online (Sandbox Code Playgroud)

如您所见,没有任何要检出文件的地址。我也尝试谷歌,看到这个这个问题,但我无法找到可以帮助我的任何事情。我该如何解决这个问题?

Ita*_*bel 5

为了更好地理解您的问题,请查看您编译的 APK。其中有一个名为“resources.arsc”的文件。这是压缩和编译的资源文件。为了能够读取它,请运行:

aapt dump --values resources myAPK.apk > c:\my-res.txt 
Run Code Online (Sandbox Code Playgroud)

现在您将拥有一个文本文件,其中包含应用程序中所有资源的描述。其中,有很多看起来像这样的片段:

type 3 configCount=2 entryCount=5
  spec resource 0x7f040000 com.LTS.NVMS7000:bool/abc_action_bar_embed_tabs: flags=0x00000080
  spec resource 0x7f040001 com.LTS.NVMS7000:bool/abc_allow_stacked_button_bar: flags=0x00000000
  spec resource 0x7f040002 com.LTS.NVMS7000:bool/abc_config_actionMenuItemAllCaps: flags=0x00000000
  spec resource 0x7f040003 com.LTS.NVMS7000:bool/abc_config_closeDialogWhenTouchOutside: flags=0x00000000
  spec resource 0x7f040004 com.LTS.NVMS7000:bool/abc_config_showMenuShortcutsWhenKeyboardPresent: flags=0x00000000
  config (default):
    resource 0x7f040000 com.LTS.NVMS7000:bool/abc_action_bar_embed_tabs: t=0x12 d=0xffffffff (s=0x0008 r=0x00)
      (color) #ffffffff
    resource 0x7f040001 com.LTS.NVMS7000:bool/abc_allow_stacked_button_bar: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
      (color) #00000000
    resource 0x7f040002 com.LTS.NVMS7000:bool/abc_config_actionMenuItemAllCaps: t=0x12 d=0xffffffff (s=0x0008 r=0x00)
      (color) #ffffffff
    resource 0x7f040003 com.LTS.NVMS7000:bool/abc_config_closeDialogWhenTouchOutside: t=0x12 d=0xffffffff (s=0x0008 r=0x00)
      (color) #ffffffff
    resource 0x7f040004 com.LTS.NVMS7000:bool/abc_config_showMenuShortcutsWhenKeyboardPresent: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
      (color) #00000000
  config port:
    resource 0x7f040000 com.LTS.NVMS7000:bool/abc_action_bar_embed_tabs: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
      (color) #00000000
Run Code Online (Sandbox Code Playgroud)

在此部分中,您可以看到有 2 个配置和 5 个预期条目。为了了解正在发生的事情,您应该做的是查看以下示例:

资源0x0101053d

它会出现在您的日志中,并查看该部分中的位置。它应该提示您应用程序中的哪个资源组导致了该问题。我猜你正在链接一个非常旧的包,因此编译器没有将该包的资源正确链接到你的应用程序,因为它们适用于不同的 Android SDK 版本。很抱歉我无法提供更多帮助。

如果您有更多信息,请对此答案发表评论,我会尽力提供帮助。


小智 0

我认为 Itamar 正确地指出了“……编译器没有将该包的资源正确链接到您的应用程序,因为它们适用于不同的 Android SDK 版本……”

我遇到了同样的问题,但按照 AS 的提示,我在这里找到了解决方案:https ://chris.banes.me/2016/02/25/appcompat-vector/#enabling-the-flag

androidstudio截图