Android 使用即时运行时出现VerifyError
当到达Android 使用即时运行时出现VerifyError,android,instant-run,Android,Instant Run,当到达XpInsetDrawable.create(Drawable,int)(下面的代码)时,将抛出VerifyError。不使用即时运行时不会发生这种情况 我正在使用Android Studio 2.0.0和gradle构建插件2.0.0。在sdk22上测试。在SDK 19模拟器上运行时,整个模拟器将重新启动 我正在寻找一个解决方案,而不是“禁用即时运行” 异常(整个堆栈跟踪不相关) 类源代码 final class XpInsetDrawable extends InsetDrawable
XpInsetDrawable.create(Drawable,int)
(下面的代码)时,将抛出VerifyError
。不使用即时运行时不会发生这种情况
我正在使用Android Studio 2.0.0和gradle构建插件2.0.0。在sdk22上测试。在SDK 19模拟器上运行时,整个模拟器将重新启动
我正在寻找一个解决方案,而不是“禁用即时运行”
异常(整个堆栈跟踪不相关)
类源代码
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;
}
}
final类XpInsetDrawable扩展了InsetDrawable{
私有静态final boolean NEEDS_FIXING=Build.VERSION.SDK_INT<21;
private final Rect mInset=new Rect();
公共静态可插入可绘制创建(最终可绘制可绘制、最终整数可插入、最终整数可插入、最终整数可插入、最终整数可插入、最终整数可插入底部){
如果(需要修理){
返回新的XPInsertDrawable(drawable、InsertLeft、InsertTop、InsertRight、InsertBottom);
}否则{
返回新的可插入式绘图(可绘制、插入式绘图、插入式绘图、插入式绘图、插入式绘图、插入式绘图底部);
}
}
公共静态插入可绘制创建(最终可绘制,最终整型插入){
如果(需要修理){
返回新的XPInsertDrawable(drawable,inset);
}否则{
返回新的可插入绘制(可绘制,插入);
}
}
XPInsertDrawable(最终可绘制可绘制,最终整数插入){
超级(可拉伸,插入);
小插曲集(插图,插图,插图,插图);
}
XPInsertDrawable(最终可绘制可绘制、最终整型插入、最终整型插入、最终整型插入、最终整型插入底部){
超级(可拉拔、插拔、插拔、插拔、插拔底部);
mInset.套装(插页、插页、插页、插页底部);
}
@凌驾
public int getIntrinsicHeight(){
返回super.getIntrinsicHeight()+mInset.top+mInset.bottom;
}
@凌驾
public int getIntrinsicWidth(){
返回super.getIntrinsicWidth()+mInset.left+mInset.right;
}
}
更新2016-08-25:Android Studio 2.2-beta3中发布的修复程序
更新2016-07-15:修复程序的目标版本现在是Android Studio 2.3
我向Android提交了一个bug,下面是dev对此的看法: 有趣 XPInsertDrawable是InsertDrawable的一个子类,其父类在23年中发生了更改。从23年开始,InsertDrawable子类DrawableWrapper在23年添加。该应用程序是使用CompileSDK版本23编译的,因此我们为DrawableWrapper方法生成方法访问 现在,当你继续运行时,你有没有按照建议在@ianhanniballake提交错误
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;
}
}