我在使用:ToastUtils.showShort("aa");的时候报如下错误
java.lang.NoClassDefFoundError: android.support.v4.widget.TextViewCompat
at com.blankj.utilcode.util.ToastUtils$1.run(ToastUtils.java:214)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5291)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
查看了你的源码:
private static void show(final CharSequence text, final int duration) {
HANDLER.post(new Runnable() {
@Override
public void run() {
cancel();
sToast = Toast.makeText(Utils.getApp(), text, duration);
// solve the font of toast
TextView tvMessage = (TextView) sToast.getView().findViewById(android.R.id.message);
TextViewCompat.setTextAppearance(tvMessage, android.R.style.TextAppearance);
tvMessage.setTextColor(msgColor);
setBgAndGravity();
sToast.show();
}
});
}
由于我的项目没有依赖v4和V7jar包,也不想依赖这些jar包,建议不设置textview的兼容,这样会不会让你的项目兼容性更好呢?
我在使用:ToastUtils.showShort("aa");的时候报如下错误 java.lang.NoClassDefFoundError: android.support.v4.widget.TextViewCompat at com.blankj.utilcode.util.ToastUtils$1.run(ToastUtils.java:214) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5291) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) at dalvik.system.NativeStart.main(Native Method)
查看了你的源码: private static void show(final CharSequence text, final int duration) { HANDLER.post(new Runnable() { @Override public void run() { cancel(); sToast = Toast.makeText(Utils.getApp(), text, duration); // solve the font of toast TextView tvMessage = (TextView) sToast.getView().findViewById(android.R.id.message); TextViewCompat.setTextAppearance(tvMessage, android.R.style.TextAppearance); tvMessage.setTextColor(msgColor); setBgAndGravity(); sToast.show(); } }); } 由于我的项目没有依赖v4和V7jar包,也不想依赖这些jar包,建议不设置textview的兼容,这样会不会让你的项目兼容性更好呢?