WindySha / XSkinLoader

侵入性最低,功能强大的Android换肤框架XSkinLoader
Other
173 stars 39 forks source link

vivo手机报错No field View in class Lcom/android/internal/R$styleable #18

Open HQiang opened 2 years ago

HQiang commented 2 years ago

真的是见鬼啊,ExtraAttrRegister里面注册的换肤拓展统统报错。包括demo中提供的ViewBackgroundStyleParser和TextViewTextColorStyleParser,parseXmlStyle方法中TypedArray a = context.obtainStyledAttributes(attrs, textViewStyleable, 0, 0);这一句报错,错误信息如下: Caused by: android.view.InflateException: Binary XML file line #19 in com.yunmai.citycall:layout/activity_main: Error inflating class RadioButton Caused by: java.lang.NullPointerException: Attempt to get length of null array at android.content.res.ResourcesImpl$ThemeImpl.obtainStyledAttributes(ResourcesImpl.java:1555) at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java:1755) at android.content.Context.obtainStyledAttributes(Context.java:784) at com.wind.me.xskinloader.parser.TextViewTextColorStyleParser.parseXmlStyle(TextViewTextColorStyleParser.java:36) at com.wind.me.xskinloader.StyleParserFactory.parseStyle(StyleParserFactory.java:35) at com.wind.me.xskinloader.parser.SkinAttributeParser.parseSkinAttr(SkinAttributeParser.java:41) at com.wind.me.xskinloader.SkinInflaterFactory.parseAndSaveSkinAttr(SkinInflaterFactory.java:120) at com.wind.me.xskinloader.SkinInflaterFactory.onCreateView(SkinInflaterFactory.java:67)

其他手机又没有这个问题。问题手机型号vivo Y30g, Android 版本11。

HQiang commented 2 years ago

ReflectUtils类中的findField反射时报的错,No field View in class Lcom/android/internal/R$styleable

private static Field findField(Class<?> clazz, String name) { try { return clazz.getDeclaredField(name); } catch (NoSuchFieldException e) { if (clazz.equals(Object.class)) { e.printStackTrace(); return null; } Class<?> base = clazz.getSuperclass(); return findField(base, name); } }