Resources NotFoundException

Viewed 509

I trying to build release version of apk and get error when launching on Honor 5x (api 23):

Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class com.google.android.gms.common.SignInButton
File res/color/abc_hint_foreground_material_light.xml from color state list resource ID #0x7f0d01e7

At the same time app doesnt crash on emulator (api 25). I've tried to add this to proguard rules but it didn't help:

-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-keepclassmembers class **.R$* {
       public static <fields>;
}

Build type:

release {
            shrinkResources true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
            debuggable true
            minifyEnabled true
        }

I use android studio 3.0 canary 1, suport library 25.3.1, build tools 25.0.2 and firebase-ui 1.2.0

Please, help me find a solution for this issue.

1 Answers

I am facing similar problems when using "shrinkResources true".

Later I got help with reference to this section Customize which resources to keep.

If there are specific resources you wish to keep or discard, create an XML file in your project with a tag and specify each resource to keep in the tools:keep attribute and each resource to discard in the tools:discard attribute. Both attributes accept a comma-separated list of resource names. You can use the asterisk character as a wild card.

Add a whitelist to the "keep.xml" file in the path "res/raw/", used to reserve resources that were lost due to "shrinkResources true".

For example "res/raw/keep.xml"

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@layout/l_used*_c,@layout/l_used_a,@layout/l_used_b*"
    tools:discard="@layout/unused2" />
Related