Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: java.lang.VerifyError because of a Generic Class
    primarykey
    data
    text
    <p>So I'm developing an Android App and I've had <code>java.lang.VerifyError</code> for the last couple of days. <br>I read in a stackoverflow post that this error was due to a problem in the returns (expected return is not the one it gets).</p> <p>So I believe this is due to a Generic Class that is casted into a String and I was hoping someone has a solution!</p> <p><strong>This is the generic Class:</strong></p> <pre><code>public class ProcessJson { public enum MessageType{ GetAppName, GetItemsList } public static Object ProcessResult(MessageType messageType, String result) throws MalformedJsonException{ Gson gson = new Gson(); Object returnValue = null; switch(messageType){ case GetAppName : returnValue = gson.fromJson(result, String.class); return returnValue; case GetItemsList : returnValue = gson.fromJson(result, Item[].class); return returnValue; } return null; } } </code></pre> <hr> <p><strong>Here is where I cast the class:</strong></p> <pre><code>public void LoginBtn_OnClick(View v){ ItemAdapter adapter = (ItemAdapter)this.itemListView.getAdapter(); //Clearing the ListView if(adapter != null) { this.itemListView.setAdapter(null); } //Fetch the AplicationName String username = this.editTextUsername.getText().toString(); String appName = RESTClient.connect("ip/DevTest/WcfApi/Api1.svc/api1/appName", username); try { appName = (String)ProcessJson.ProcessResult(MessageType.GetAppName, appName); appNameTextView.setText("Logged in as: " + appName); } catch (MalformedJsonException e) { e.printStackTrace(); appNameTextView.setText("Cannot Login"); } catch (JsonSyntaxException e){ e.printStackTrace(); appNameTextView.setText("Cannot Login"); } //Fetch the itemList String itemList = RESTClient.connect("ip/DevTest/WcfApi/Api1.svc/api1/items", username); try{ Item[] items = (Item[])ProcessJson.ProcessResult(MessageType.GetItemsList, itemList); //Binding itemList to UI //ItemAdapter itemAdapter = new ItemAdapter(this, R.layout.item_row, items); //this.itemListView.setAdapter(itemAdapter); } catch (MalformedJsonException e) { e.printStackTrace(); appNameTextView.setText("Cannot Login"); } catch (JsonSyntaxException e){ e.printStackTrace(); appNameTextView.setText("Cannot Login"); } } </code></pre> <p>I manage to avoid the crash when I put the two try/catch blocks as a comment. This is what lead me to believe the problem is due to the ProcessJson class.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload