Unable to find resource ID - Android Gradle Plugin 3.4.0

时间秒杀一切 提交于 2019-12-08 15:55:56

问题


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);
    }

来源:https://stackoverflow.com/questions/57206223/unable-to-find-resource-id-android-gradle-plugin-3-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!