设备上的VerifyError,适用于虚拟设备

时间:2015-06-29 08:41:09

标签: android

星期五我的应用运行正常。我做了一些改动(没有任何涉及罐子,或者太奇怪的东西),现在我无法在我的物理设备上运行它。无论如何,它在虚拟设备中运行正常。这是堆栈跟踪:

06-29 10:34:09.464  12347-12347/? W/dalvikvm﹕ VFY: unable to find class referenced in signature ([Landroid/util/Size;)
06-29 10:34:09.464  12347-12347/? W/dalvikvm﹕ VFY: returning Ljava/lang/Object; (cl=0x0), declared [Ljava/lang/Object; (cl=0x0)
06-29 10:34:09.464  12347-12347/? W/dalvikvm﹕ VFY:  rejecting opcode 0x11 at 0x0002
06-29 10:34:09.464  12347-12347/? W/dalvikvm﹕ VFY:  rejected Lmy/package/activities/SplashScreenActivity;.access$300 (Lmy/package/lpi/activities/SplashScreenActivity;)[Landroid/util/Size;
06-29 10:34:09.464  12347-12347/? W/dalvikvm﹕ Verifier rejected class Lmy/package/activities/SplashScreenActivity;
06-29 10:34:09.464  12347-12347/? W/dalvikvm﹕ Class init failed in newInstance call (Lmy/package/activities/SplashScreenActivity;)
06-29 10:34:09.464  12347-12347/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41adbd88)
06-29 10:34:09.474  12347-12347/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: my.package, PID: 12347
java.lang.VerifyError: my/package/activities/SplashScreenActivity
        at java.lang.Class.newInstanceImpl(Native Method)
        at java.lang.Class.newInstance(Class.java:1208)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1062)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2166)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2313)
        at android.app.ActivityThread.access$800(ActivityThread.java:144)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5212)
        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:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
        at dalvik.system.NativeStart.main(Native Method)

有什么想法吗?我经历了一场噩梦...

PD:我正在使用Android Studio,我的jars在libs文件夹中。

1 个答案:

答案 0 :(得分:0)

VFY: unable to find class referenced in signature ([Landroid/util/Size;)

您的物理Android设备不支持添加了类android.util.Size的API级别21。但是,该类并不复杂,除非您需要使用基于该类的参数调用方法,否则实现类似的操作应该很简单。基本上,Size只是一个围绕两个整数的不可变包装器,表示某些东西的宽度和高度。

班级的核心是:

/**
 * Create a new immutable Size instance.
 *
 * @param width The width of the size, in pixels
 * @param height The height of the size, in pixels
 */
public Size(int width, int height) {
    mWidth = width;
    mHeight = height;
}

/**
 * Get the width of the size (in pixels).
 * @return width
 */
public int getWidth() {
    return mWidth;
}

/**
 * Get the height of the size (in pixels).
 * @return height
 */
public int getHeight() {
    return mHeight;
}

正如我所说,只是一个简单的包装。然后有一些格式化/解析实用程序:

/**
 * Return the size represented as a string with the format {@code "WxH"}
 *
 * @return string representation of the size
 */
@Override
public String toString() {
    return mWidth + "x" + mHeight;
}

/**
 * Parses the specified string as a size value.
 * <p>
 * The ASCII characters {@code \}{@code u002a} ('*') and
 * {@code \}{@code u0078} ('x') are recognized as separators between
 * the width and height.</p>
 * <p>
 * For any {@code Size s}: {@code Size.parseSize(s.toString()).equals(s)}.
 * However, the method also handles sizes expressed in the
 * following forms:</p>
 * <p>
 * "<i>width</i>{@code x}<i>height</i>" or
 * "<i>width</i>{@code *}<i>height</i>" {@code => new Size(width, height)},
 * where <i>width</i> and <i>height</i> are string integers potentially
 * containing a sign, such as "-10", "+7" or "5".</p>
 *
 * <pre>{@code
 * Size.parseSize("3*+6").equals(new Size(3, 6)) == true
 * Size.parseSize("-3x-6").equals(new Size(-3, -6)) == true
 * Size.parseSize("4 by 3") => throws NumberFormatException
 * }</pre>
 *
 * @param string the string representation of a size value.
 * @return the size value represented by {@code string}.
 *
 * @throws NumberFormatException if {@code string} cannot be parsed
 * as a size value.
 * @throws NullPointerException if {@code string} was {@code null}
 */
public static Size parseSize(String string)
        throws NumberFormatException {
    checkNotNull(string, "string must not be null");

    int sep_ix = string.indexOf('*');
    if (sep_ix < 0) {
        sep_ix = string.indexOf('x');
    }
    if (sep_ix < 0) {
        throw invalidSize(string);
    }
    try {
        return new Size(Integer.parseInt(string.substring(0, sep_ix)),
                Integer.parseInt(string.substring(sep_ix + 1)));
    } catch (NumberFormatException e) {
        throw invalidSize(string);
    }
}

此外,该课程会覆盖equals()hashCode(),但许多应用可能不会需要。

如果您只需要包装器功能,则可以基于android.util.Size的核心创建自己的类。