0

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;
}
Rafael T
  • 15,401
  • 15
  • 83
  • 144
  • The doc for java.lang.VerifyError says this "Thrown when the "verifier" detects that a class file, though well formed, contains some sort of internal inconsistency or security problem." so you'll probably need to post more of your code for people to be able to help you. – Anthony Grist Jul 07 '11 at 20:41
  • Are you using external libraries in your program? Particulary, are you referencing any external libraries from the ConnectionHelper.getTicketRequestJsonString method? See here - http://stackoverflow.com/questions/668788/android-java-lang-verifyerror. – Perception Jul 07 '11 at 20:43
  • @Perception Yes I use, but not in this Method as you see in my Edit – Rafael T Jul 07 '11 at 20:50
  • @Andreas_D java.lang.VerifyError: namespace.helper.ConnectionHelper at namespace.Service.continueLoggedInLogic(TService.java:399) – Rafael T Jul 07 '11 at 20:52

2 Answers2

0

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.

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • as you can see, this class ConnectionHelper has nothing to do with Android SDK itself. Also I'm not using android libs for higher API levels then my build-level – Rafael T Jul 08 '11 at 10:05
  • @Rafael T: "as you can see" -- no, I cannot see, because you are thousands of miles away, and your monitor is turned in the wrong direction. If you think that you pasted an entire class into your question, you are mistaken. "Also I'm not using android libs for higher API levels then my build-level" -- that does not matter. What matters is what devices are running your application and if you are using classes that do not exist on those devices. – CommonsWare Jul 08 '11 at 10:13
  • sorry for "as you can see". I assumed that the stackTrace is pointing to the Class which is not there, and its pointing to ConnectionHelper. – Rafael T Jul 08 '11 at 13:01
  • @Rafael T: No, the stack trace does not point to the `Class` which is not there, but rather the `Class` that is *referencing* stuff that is not there. – CommonsWare Jul 08 '11 at 13:06
  • so there is one Method in my ConnectionHelper using GSON to convert JSON to native-Java Objects. This Lib is into my build-path. Can it be, that Gson is using stuff, not all Androids have? – Rafael T Jul 08 '11 at 13:42
  • @Rafael T: Conceivably, yes. Test your app in older Android versions in the emulator. – CommonsWare Jul 08 '11 at 13:46