bilibili / MagicaSakura

MagicaSakura 是 Android 多主题框架。~ is an Android multi theme library which supporting both daily colorful theme and night theme.
http://app.bilibili.com
Apache License 2.0
3.55k stars 468 forks source link

添加IntButton在布局的时候报错 #64

Open hlzIrving opened 5 years ago

hlzIrving commented 5 years ago

布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity">

<com.bilibili.magicasakura.widgets.TintButton
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="123"/>

错误:Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.bilibili.magicasakura.widgets.TintButton

我添加了依赖implementation 'com.bilibili:magicasakura:0.1.8@aar' 内部的属性也没错,所以不太清楚为啥会报这个错误,本人用的是4.4.2夜神模拟器跑的

xyczero commented 5 years ago

整个布局加载只有TintButton出错了?那可能需要你debug看下TintButton初始化时具体发生的错误了

hlzIrving commented 5 years ago

整个布局加载只有TintButton出错了?那可能需要你debug看下TintButton初始化时具体发生的错误了

我把依赖删除,使用库的形式添加magicasakura,在TintButton内打断点,也是在4.4.2夜神模拟器运行,竟然没有崩溃,成功跑起来了。所以,这到底是啥原因崩溃的。

xyczero commented 5 years ago

😂那通过依赖的形式打断点看看呢

hlzIrving commented 5 years ago

joy那通过依赖的形式打断点看看呢

Caused by: java.lang.NoClassDefFoundError: android.support.v4.graphics.drawable.DrawableWrapper at com.bilibili.magicasakura.utils.ThemeUtils.getWrapperDrawable(ThemeUtils.java:270) at com.bilibili.magicasakura.utils.ThemeUtils.containsNinePatch(ThemeUtils.java:245) at com.bilibili.magicasakura.widgets.AppCompatBackgroundHelper.recoverPadding(AppCompatBackgroundHelper.java:197) at com.bilibili.magicasakura.widgets.AppCompatBackgroundHelper.setBackgroundDrawable(AppCompatBackgroundHelper.java:122) at com.bilibili.magicasakura.widgets.AppCompatBackgroundHelper.loadFromAttribute(AppCompatBackgroundHelper.java:65) at com.bilibili.magicasakura.widgets.TintButton.(TintButton.java:59) at com.bilibili.magicasakura.widgets.TintButton.(TintButton.java:48) at java.lang.reflect.Constructor.constructNative(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  at android.view.LayoutInflater.createView(LayoutInflater.java:594)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)  依赖下断点在这里报错了。4.4.2夜神模拟器运行

xyczero commented 5 years ago

😯这个类是v4里的。。。感觉是模拟器的锅