Resource Not Found error res/drawable/abc_switch_thumb_material.xml after adding SwitchCompat in Android App Bundle
Asked Answered
H

3

16

I Know this Question has been asked several times i have read them all and have matched all dependencies so that they have same versions but this error only started to happen after adding Switch Compat as you can also see that by going through the crash report by fabric . This Error is happing not on all devices but to some by the crash report , also it has no specific Android for this crash. One More thing i am using beta versions of android because of Android App Bundle and this thing does not happen in non bundles that is Apk.

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.App/com.App}: android.view.InflateException: Binary XML file line #100: Error inflating class android.support.design.widget.NavigationView
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3190)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
       at android.app.ActivityThread.access$1000(ActivityThread.java:211)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:6946)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Caused by android.view.InflateException: Binary XML file line #100: Error inflating class android.support.design.widget.NavigationView
       at android.view.LayoutInflater.createView(LayoutInflater.java:640)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
       at android.support.v7.app.l.b(Unknown Source)
       at android.support.v7.app.e.setContentView(Unknown Source)
       at com.App.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6575)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3143)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
       at android.app.ActivityThread.access$1000(ActivityThread.java:211)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:6946)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Caused by java.lang.reflect.InvocationTargetException
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
       at android.support.v7.app.l.b(Unknown Source)
       at android.support.v7.app.e.setContentView(Unknown Source)
       at com.App.MainActivity.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6575)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3143)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
       at android.app.ActivityThread.access$1000(ActivityThread.java:211)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:6946)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Caused by android.view.InflateException: Binary XML file line #3: Error inflating class android.support.v7.widget.SwitchCompat
       at android.view.LayoutInflater.createView(LayoutInflater.java:640)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.support.v7.view.menu.j.a(Unknown Source)
       at android.support.v7.view.menu.j.setActionView(Unknown Source)
       at android.support.v7.view.g$b.a(Unknown Source)
       at android.support.v7.view.g$b.b(Unknown Source)
       at android.support.v7.view.g.a(Unknown Source)
       at android.support.v7.view.g.a(Unknown Source)
       at android.support.v7.view.g.inflate(Unknown Source)
       at android.support.design.widget.NavigationView.a(Unknown Source)
       at android.support.design.widget.NavigationView.<init>(Unknown Source)
       at android.support.design.widget.NavigationView.<init>(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
       at android.support.v7.app.l.b(Unknown Source)
       at android.support.v7.app.e.setContentView(Unknown Source)
       at com.App.MainActivity.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6575)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3143)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
       at android.app.ActivityThread.access$1000(ActivityThread.java:211)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:6946)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Caused by java.lang.reflect.InvocationTargetException
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.support.v7.view.menu.j.a(Unknown Source)
       at android.support.v7.view.menu.j.setActionView(Unknown Source)
       at android.support.v7.view.g$b.a(Unknown Source)
       at android.support.v7.view.g$b.b(Unknown Source)
       at android.support.v7.view.g.a(Unknown Source)
       at android.support.v7.view.g.a(Unknown Source)
       at android.support.v7.view.g.inflate(Unknown Source)
       at android.support.design.widget.NavigationView.a(Unknown Source)
       at android.support.design.widget.NavigationView.<init>(Unknown Source)
       at android.support.design.widget.NavigationView.<init>(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
       at android.support.v7.app.l.b(Unknown Source)
       at android.support.v7.app.e.setContentView(Unknown Source)
       at com.App.MainActivity.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6575)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3143)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
       at android.app.ActivityThread.access$1000(ActivityThread.java:211)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:6946)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Caused by android.content.res.Resources$NotFoundException: File res/drawable/abc_switch_thumb_material.xml from drawable resource ID #0x7f080048
       at android.content.res.Resources.loadDrawableForCookie(Resources.java:3985)
       at android.content.res.Resources.loadDrawable(Resources.java:3853)
       at android.content.res.Resources.getDrawable(Resources.java:1949)
       at android.content.Context.getDrawable(Context.java:409)
       at android.support.v4.a.a.a(Unknown Source)
       at android.support.v7.widget.l.a(Unknown Source)
       at android.support.v7.widget.l.a(Unknown Source)
       at android.support.v7.c.a.b.b(Unknown Source)
       at android.support.v7.widget.bm.a(Unknown Source)
       at android.support.v7.widget.SwitchCompat.<init>(Unknown Source)
       at android.support.v7.widget.SwitchCompat.<init>(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.support.v7.view.menu.j.a(Unknown Source)
       at android.support.v7.view.menu.j.setActionView(Unknown Source)
       at android.support.v7.view.g$b.a(Unknown Source)
       at android.support.v7.view.g$b.b(Unknown Source)
       at android.support.v7.view.g.a(Unknown Source)
       at android.support.v7.view.g.a(Unknown Source)
       at android.support.v7.view.g.inflate(Unknown Source)
       at android.support.design.widget.NavigationView.a(Unknown Source)
       at android.support.design.widget.NavigationView.<init>(Unknown Source)
       at android.support.design.widget.NavigationView.<init>(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
       at android.support.v7.app.l.b(Unknown Source)
       at android.support.v7.app.e.setContentView(Unknown Source)
       at com.App.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6575)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3143)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
       at android.app.ActivityThread.access$1000(ActivityThread.java:211)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:6946)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Caused by android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f080012
       at android.content.res.Resources.getResourceName(Resources.java:3455)
       at android.content.res.Resources.loadDrawableForCookie(Resources.java:3941)
       at android.content.res.Resources.loadDrawable(Resources.java:3853)
       at android.content.res.TypedArray.getDrawable(TypedArray.java:776)
       at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
       at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
       at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1192)
       at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1086)
       at android.content.res.Resources.loadDrawableForCookie(Resources.java:3969)
       at android.content.res.Resources.loadDrawable(Resources.java:3853)
       at android.content.res.Resources.getDrawable(Resources.java:1949)
       at android.content.Context.getDrawable(Context.java:409)
       at android.support.v4.a.a.a(Unknown Source)
       at android.support.v7.widget.l.a(Unknown Source)
       at android.support.v7.widget.l.a(Unknown Source)
       at android.support.v7.c.a.b.b(Unknown Source)
       at android.support.v7.widget.bm.a(Unknown Source)
       at android.support.v7.widget.SwitchCompat.<init>(Unknown Source)
       at android.support.v7.widget.SwitchCompat.<init>(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.support.v7.view.menu.j.a(Unknown Source)
       at android.support.v7.view.menu.j.setActionView(Unknown Source)
       at android.support.v7.view.g$b.a(Unknown Source)
       at android.support.v7.view.g$b.b(Unknown Source)
       at android.support.v7.view.g.a(Unknown Source)
       at android.support.v7.view.g.a(Unknown Source)
       at android.support.v7.view.g.inflate(Unknown Source)
       at android.support.design.widget.NavigationView.a(Unknown Source)
       at android.support.design.widget.NavigationView.<init>(Unknown Source)
       at android.support.design.widget.NavigationView.<init>(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
       at android.support.v7.app.l.b(Unknown Source)
       at android.support.v7.app.e.setContentView(Unknown Source)
       at com.App.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6575)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3143)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
       at android.app.ActivityThread.access$1000(ActivityThread.java:211)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:6946)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Here is my build.gradle Dependency:-

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'


implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testCompile 'junit:junit:4.12'

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'

implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'

annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.github.hotchemi:android-rate:1.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'

implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
    transitive = true;
}

implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
implementation 'petrov.kristiyan:colorpicker-library:1.1.8'}
Heliochrome answered 8/7, 2018 at 1:45 Comment(8)
I don't know if this is the reason or not, but your base errors (ResourceNotFoundException) all appear to show up after a call from the v7 support library to the v4 support library. Will it still build if you remove the support-v4:27.1.1 dependency? abc_switch_thumb_material.xml is in the v7 appcompat support library.Brunn
Yes , you are right it builds and runs perfectly without support-v4:27.1.1 , this is the thing i was noticing , any comment how to fix it?Heliochrome
If it builds and runs, isn't removing that dependency the solution? (Is there some other reason you need the v4 support library?)Brunn
I don't think this would solve the problem as support design library already contains v4 library, see imgur.com/a/V8KD6y2 and also my code uses v4 support library extensively , thanksHeliochrome
I'm confused then, what did you mean then by "it builds and runs perfectly without support-v4:27.1.1"? What am I missing here?Brunn
Its because of many dependency already contain support-v4:27.1.1 therefore it is building and running without implementation 'com.android.support:support-v4:27.1.1' as it does need it.Heliochrome
Did you find solution to that problem? I'm experiencing similar issue. Crashes caused by android.content.res.Resources$NotFoundException ... res/drawable/abc_switch_thumb_material.xm. My support dependency is androidx.appcompat:appcompat:1.0.2. It started when I switched to bundle instead of apks.Electroscope
No not till now refer this:-#50472388Heliochrome
B
4

Based on your error messages, the base error (ResourceNotFoundException) shows up after a call from the v7 support library to the v4 support library where it can't find abc_switch_thumb_material.xml (which is in the v7 library).

Remove the dependency on com.android.support:support-v4:27.1.1 from the gradle file if possible.

Brunn answered 8/7, 2018 at 3:3 Comment(1)
I have this issue without support-v4 dependency, what can be other reasons for it?Carce
P
1

If your project has munufuingEnabled and shrinkingResourses == true - add the following line to your proguard-rule

-keep class com.google.android.material.R$drawable { *; }

Peppi answered 24/10, 2022 at 10:5 Comment(0)
T
0

i am not sure what the root cause of the crash is, but the crashes stopped when i switched to using <Switch>

both <SwitchCompat> and <SwitchMaterial> caused crashes in production

Tempura answered 18/2, 2023 at 8:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.