2

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.

ackh
  • 1,648
  • 2
  • 18
  • 36

1 Answers1

2

I had this problem before is really annoying

I saw that when I built a debug apk (not an app bundle), and installed it directly from the phone (not from android studio) I didnt get that warning message in the logcat, so I thought it must be a problem with building a bundle

The solution that worked for me is:

  • In Android Studio Go to Run->Edit Configuration
  • In the General tab, Inside the installation options, change the Deploy option to "Default APK"
  • Run your app as usual

Hope this solves your problem too

  • 1
    The problem is that Google made it clear that app bundles are the future. So, delivering my app as .apk file(s) will at some point not be possible anymore. – ackh Jan 17 '21 at 09:25
  • Yes you are right!, but you shouldnt deploy from the run configuration of Android Studio, that's only for running the app when you are developing, if you want to deploy you should create a signed bundle from the build menu if you are using Android Studio, this solution is only to prevent the logcat from been filled with that warning only when you are developing. – Juan Ernesto García Alvarez Jan 22 '21 at 11:32
  • From what I see, that problem occurs if I deploy the app directly from Android Studio or via .apk or via Bundle. – ackh Jan 25 '21 at 08:29
  • 1
    For what it's worth, I too am experiencing this issue and the app is installed from the Play Store. – Bink Jan 31 '23 at 16:49