达到(下面的代码)VerifyError
时抛出A。不使用 Instant RunXpInsetDrawable.create(Drawable, int)
时不会发生这种情况。
我正在使用 Android Studio 2.0.0 和 gradle build plugin 2.0.0。在 SDK 22 上测试。在 SDK 19 模拟器上运行时,整个模拟器会重新启动。
我正在寻找“禁用即时运行”以外的解决方案。
异常(整个堆栈跟踪无关)
Caused by: java.lang.VerifyError:
Verifier rejected class net.xpece.android.support.preference.XpInsetDrawable due to bad method
java.lang.Object net.xpece.android.support.preference.XpInsetDrawable.access$super(
net.xpece.android.support.preference.XpInsetDrawable,
java.lang.String,
java.lang.Object[])
(declaration of 'net.xpece.android.support.preference.XpInsetDrawable'
appears in /data/data/net.xpece.android.support.preference.sample/files/instant-run/dex/slice-slice_7-classe
类源代码
final class XpInsetDrawable extends InsetDrawable {
private static final boolean NEEDS_FIXING = Build.VERSION.SDK_INT < 21;
private final Rect mInset = new Rect();
public static InsetDrawable create(final Drawable drawable, final int insetLeft, final int insetTop, final int insetRight, final int insetBottom) {
if (NEEDS_FIXING) {
return new XpInsetDrawable(drawable, insetLeft, insetTop, insetRight, insetBottom);
} else {
return new InsetDrawable(drawable, insetLeft, insetTop, insetRight, insetBottom);
}
}
public static InsetDrawable create(final Drawable drawable, final int inset) {
if (NEEDS_FIXING) {
return new XpInsetDrawable(drawable, inset);
} else {
return new InsetDrawable(drawable, inset);
}
}
XpInsetDrawable(final Drawable drawable, final int inset) {
super(drawable, inset);
mInset.set(inset, inset, inset, inset);
}
XpInsetDrawable(final Drawable drawable, final int insetLeft, final int insetTop, final int insetRight, final int insetBottom) {
super(drawable, insetLeft, insetTop, insetRight, insetBottom);
mInset.set(insetLeft, insetTop, insetRight, insetBottom);
}
@Override
public int getIntrinsicHeight() {
return super.getIntrinsicHeight() + mInset.top + mInset.bottom;
}
@Override
public int getIntrinsicWidth() {
return super.getIntrinsicWidth() + mInset.left + mInset.right;
}
}