Unable to find resource ID - Android Gradle Plugin 3.4.0
F

0

10

When moving from Android Gradle Plugin 3.3.2 in a multi module project to 3.4.0 and executing connectedAndroidTest I see a fatal exception. A Google Play Services shared class StringResourceValueReader looks for a resource common_google_play_services_unknown_issue but fails to find it.

The error is as follows:

    android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f0f0044
        at android.content.res.ResourcesImpl.getResourcePackageName(ResourcesImpl.java:236)
        at android.content.res.Resources.getResourcePackageName(Resources.java:1909)

I am carrying out a Gradle and AGP upgrade and so have moved to Gradle 5.1.1 and 3.4.0, however AGP 3.4.0 causes my Espresso test run to bomb out early on app initialise. In my initial scenario this behaviour is triggered by a Firebase ContentProvider, however excluding this moves the problem to the next usage of StringResourceValueReader which in my case is GoogleAds.

I have looked at the generated apks for both my app and androidTest to look at all of the resources being generated via aapt --dump values. The missing resource id does not exist in the app apk, it does exist in the test apk, however the id is attached to an unrelated resource within the androidTest source set (not even a string). The resource that is not found has a completely different res id which is available in both apks.

I assumed that the StringValueReader was being passed the incorrect Context, in my scenario perhaps it is the InstrumentationContext, I therefore added in the missing string resource alongside other firebase string resources without luck (also tried this in the app).

The offending code in StringResourceValueReader

    public StringResourceValueReader(Context var1) {
        ....
        this.zzev = this.zzeu.getResourcePackageName(string.common_google_play_services_unknown_issue);
    }
Falzetta answered 25/7, 2019 at 16:9 Comment(4)
Hi, what Google Play services or Firebase artifacts are you depending on, and at what versions?Petrapetracca
I'm dependent upon the following: - Firebase Cloud Messaging 17.5.0 (no upgrades here have an impact, i haven't moved to androidx so can't target 19+) - Play Services Maps 16.1.0 - Play Services Analytics 16.0.8 - Play Services Ads 17.2.0 The failing line of code is located in Play Services Basement 16.0.1Falzetta
Any resolution on this? I'm having the exact same issue and I can't figure out why. Happens after I migrated to AndroidX using Android Studio's Migrate tool.Mcilwain
Hi Georgi, apologies for the late response, my issue was due to agp 3.4+ generating the R files in intermediates/javac/debugUnitTest/compileDebugUnitTestJavaWithJavac/classes when using android.testOptions.unitTests.includeAndroidResources = true. I had hard coded paths that included these files in a test helper package causing the clash.Falzetta

© 2022 - 2024 — McMap. All rights reserved.