某些设备上出现java.lang.VerifyError

发布于 2024-11-19 03:30:12 字数 731 浏览 9 评论 0原文

我为我的公司编写了一个 Android 应用程序,由于它对我来说运行良好,因此出现了一些我自己从未遇到过的错误的崩溃报告。 我不知道如何修复一个服务中的 java.lang.verifyError 错误。

崩溃的行是:

String post_request = ConnectionHelper.getTicketRequestJsonString(true, ticketIdsToDownload);

ConnectionHelper 是一个仅包含返回字符串的静态函数的类。我可以做什么来解决这个问题?

编辑:如果有帮助,我会发布一些代码,同时不认为我遇到了“安全问题”

public static String getTicketRequestJsonString(boolean details, List<String> ticketIds){
    String ticketString = "tickets:[";
    int count = ticketIds.size() - 1;
    for (int i = 0; i <= count; i++){
        String s = ticketIds.get(i);
        ticketString += s
        ticketString += i != count ? "," : "]";
    }
    return ticketString;
}

I have written an Android App for my Company, and as it runs well for me, there are some crash-reports with errors I never had myself.
One I don't know how to fix is a java.lang.verifyError in a Service.

the line which is crashing is:

String post_request = ConnectionHelper.getTicketRequestJsonString(true, ticketIdsToDownload);

ConnectionHelper is a class containing only static functions returning Strings. What can I do to fix the problem?

Edit: if helpfull i'll post some Code while not thinking I'm running into "Security Problems"

public static String getTicketRequestJsonString(boolean details, List<String> ticketIds){
    String ticketString = "tickets:[";
    int count = ticketIds.size() - 1;
    for (int i = 0; i <= count; i++){
        String s = ticketIds.get(i);
        ticketString += s
        ticketString += i != count ? "," : "]";
    }
    return ticketString;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乙白 2024-11-26 03:30:12

当 Android 尝试加载引用不可用内容的类时,会发生 VerifyError。一个示例是在 Android 2.1 设备上运行时加载引用 Android 3.0 类的类。

我可以做什么来解决这个问题?

确定具体无法加载的内容,然后确定如何处理该问题。例如,有一些技巧可以避免在 Android 2.1 设备上加载 Android 3.0 类,同时仍然在 Android 3.x 设备上使用 Android 3.0 类。

A VerifyError occurs when Android tries to load a class that refers to things that are not available. An example would be loading a class that refers to Android 3.0 classes, when running on an Android 2.1 device.

What can I do to fix the problem?

Identify what specifically it cannot load, then determine how to deal with that. For example, there are tricks to be able to avoid loading Android 3.0 classes on an Android 2.1 device, while still using the Android 3.0 classes on an Android 3.x device.

把人绕傻吧 2024-11-26 03:30:12

我在这里也遇到了同样的问题;最后发现受影响的类

try {
localIP = InetAddress.getLocalHost().getHostAddress();
} catch (NetworkOnMainThreadException ex) {         
}

在Android 2.3上使用This failed with verifyError。

删除 NetworkOnMainThreadException 的使用,它再次适用于 2.3。

i had the same issue here; and finally found that the affected class uses

try {
localIP = InetAddress.getLocalHost().getHostAddress();
} catch (NetworkOnMainThreadException ex) {         
}

This failed with VerifyError on Android 2.3.

removing the use of NetworkOnMainThreadException, it works on 2.3 again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文