简体   繁体   中英

java.lang.VerifyError occurs on some devices

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;
}

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM