Android - loadDrawableForCook ie Ресурсы $ NotFoundException в setContentView - PullRequest
0 голосов
/ 30 мая 2020

Эта ошибка sh возникает на некоторых устройствах Android 6.0, когда setContentView() вызывается в Activity.onCreate()

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3319)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3415)
  at android.app.ActivityThread.access$1100 (ActivityThread.java:229)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1821)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:7325)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: android.view.InflateException: 
  at android.view.LayoutInflater.inflate (LayoutInflater.java:551)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:429)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:380)
  at com.android.internal.policy.PhoneWindow.setContentView (PhoneWindow.java:479)
  at android.app.Activity.setContentView (Activity.java:2400)
  at MyActivity.onCreate (MyActivity.java:42)
  at android.app.Activity.performCreate (Activity.java:6904)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1136)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3266)
Caused by: android.view.InflateException: 
  at android.view.LayoutInflater.createView (LayoutInflater.java:657)
  at com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
  at android.view.LayoutInflater.onCreateView (LayoutInflater.java:706)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:774)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:716)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:847)
  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:495)
Caused by: java.lang.reflect.InvocationTargetException: 
  at java.lang.reflect.Constructor.newInstance (Native Method)
  at android.view.LayoutInflater.createView (LayoutInflater.java:631)
Caused by: android.content.res.Resources$NotFoundException: 
  at android.content.res.Resources.loadDrawableForCookie (Resources.java:4289)
  at android.content.res.Resources.loadDrawable (Resources.java:4158)
  at android.content.res.Resources.loadDrawable (Resources.java:4003)
  at android.content.res.TypedArray.getDrawable (TypedArray.java:886)
  at android.view.View.<init> (View.java:4242)
  at android.widget.TextView.<init> (TextView.java:961)
  at android.widget.Button.<init> (Button.java:112)
  at android.widget.Button.<init> (Button.java:105)
  at android.widget.Button.<init> (Button.java:101)
Caused by: org.xmlpull.v1.XmlPullParserException: 
  at android.graphics.drawable.StateListDrawable.inflateChildElements (StateListDrawable.java:182)
  at android.graphics.drawable.StateListDrawable.inflate (StateListDrawable.java:115)
  at android.graphics.drawable.Drawable.createFromXmlInner (Drawable.java:2551)
  at android.graphics.drawable.Drawable.createFromXml (Drawable.java:2322)
  at android.content.res.Resources.loadDrawableForCookie (Resources.java:4279)

Есть ли исправление или обходной путь для этого?

1 Ответ

0 голосов
/ 30 мая 2020

Я думаю, вы передаете нулевой макет / представление в методе setContentView. Можете ли вы прикрепить метод и передаваемый параметр?

...