After compiling (with Android Studio 4.1.1 / Gradle 6.5 / Android Gradle Plugin 4.1.0) and running my Android app the log is littered with warnings such as the following:
...
12-19 12:16:01.239 10869 10869 W ResourceType: For resource 0x7f12016b, entry index(363) is beyond type entryCount(184)
12-19 12:16:01.239 10869 10869 W ResourceType: For resource 0x7f12016c, entry index(364) is beyond type entryCount(184)
12-19 12:16:01.239 10869 10869 W ResourceType: For resource 0x7f120275, entry index(629) is beyond type entryCount(184)
12-19 12:16:01.239 10869 10869 W ResourceType: For resource 0x7f120274, entry index(628) is beyond type entryCount(184)
12-19 12:16:01.250 10869 10869 W ResourceType: For resource 0x7f120248, entry index(584) is beyond type entryCount(184)
...
Dumping the content of the resource.arsc
file that is part of the .apk file using the command "C:\AndroidSDK\build-tools\29.0.2\aapt2.exe" dump resources myApp.apk > myApp.resources.txt
allows me to map those hex addresses to actual resource names. Mapping those addresses shown above reveals that the following resources are the source of those warnings:
...
resource 0x7f12016b -> style/TextAppearance.AppCompat.SearchResult.Subtitle
resource 0x7f12016c -> style/TextAppearance.AppCompat.SearchResult.Title
resource 0x7f120275 -> style/Widget.AppCompat.Toolbar.Button.Navigation
resource 0x7f120274 -> style/Widget.AppCompat.Toolbar
resource 0x7f120248 -> style/Widget.AppCompat.Light.ActionBar.Solid
...
So, these are resources that end up in my app due to Google's androidx.appcompat
library.
Checking the resources.txt file that gets written as part of a build reveals the following entries about those resources:
...
Marking style:TextAppearance_AppCompat_SearchResult_Subtitle:2131886443 used because its prefix matches string pool constant TextAppearance
Marking style:TextAppearance_AppCompat_SearchResult_Title:2131886444 used because its prefix matches string pool constant TextAppearance
style:Base_Widget_AppCompat_Toolbar_Button_Navigation:2131886298 => [attr:controlBackground:2130968810]
style:Widget_AppCompat_Toolbar:2131886708 => [style:Base_Widget_AppCompat_Toolbar:2131886297]
style:Widget_AppCompat_Light_ActionBar_Solid:2131886664 => [style:Base_Widget_AppCompat_Light_ActionBar_Solid:2131886269]
...
And just to be really sure that all resources are actually part of the .apk file I inspected the .apk file using Android Studio's APK Analyzer but I could see nothing suspicious.
So, I checked what I could find in the Android source code and came across the following Android C++ source code:
// Check that the entry idx is within range of the declared entry count (ResTable_typeSpec).
// Particular types (ResTable_type) may be encoded with sparse entries, and so their
// entryCount do not need to match.
if (static_cast<size_t>(realEntryIndex) >= typeSpec->entryCount) {
ALOGW("For resource 0x%08x, entry index(%d) is beyond type entryCount(%d)",
Res_MAKEID(packageGroup->id - 1, typeIndex, entryIndex),
entryIndex, static_cast<int>(typeSpec->entryCount));
// We should normally abort here, but some legacy apps declare
// resources in the 'android' package (old bug in AAPT).
continue;
}
However, I'm not sure about the context of that code or what it or its comment are trying to tell me.
For reference, the following build.gradle
settings are used to build the app:
android
{
compileSdkVersion 29
buildToolsVersion "29.0.2"
...
defaultConfig
{
minSdkVersion 16
targetSdkVersion 29
...
}
...
}
Does anyone have any idea what to do about this warning? I know that it is just a warning and not an error and that I could ignore it. But it needlessly spams Android's log which is why I want to get rid of it.
That problem is not new. Similar questions have been asked here and here but the available answers don't resolve this problem.