Android Verifier failure due to class length?
<p>I'm programming my first, and admittedly amateurish, android project.  Currently I'm creating buttons inside a viewpager class but I reached a point where adding code, any code, inside the instantiateItem cause the viewpager to fail.  Even code that doesn't do anything, for example:
<code>int a = 1;</code>
causes the crash as long as it seems to be the critical line number.  The whole program runs great, and then I add one line, any code, anywhere inside instantiateItem, and it crashes.  Android build target is 4.0, min sdk is 14.  Crash occurs on both the emulator and on my galaxy nexus phone. Total length of code inside the viewpager is 1000 lines including comments and white space, with those removed it is about 850 lines.  </p>

<p>Exact Error:</p>

<p>VFY: invalid switch target 26 (-> 0x9e0) at 0x9c6[1]</p>

<p>VFY: rejecting opcode 0x2b at 0x9c6</p>

<p>W/dalvikvm(8886): VFY:  rejected Lcharacter/sheet/CharacterViewer$MyPagerAdapter;.instantiateItem (Landroid/view/View;I)Ljava/lang/Object;</p>

<p>W/dalvikvm(8886): Verifier rejected class Lcharacter/sheet/CharacterViewer$MyPagerAdapter;</p>

<p>W/dalvikvm(8886): threadid=1: thread exiting with uncaught exception (group=0x40a661f8)</p>

<p>E/AndroidRuntime(8886): java.lang.VerifyError: character/sheet/CharacterViewer$MyPagerAdapter</p>

<p>code for character viewer activity:</p>

<pre><code>public class CharacterViewer extends Activity { 
final DBAdapter db = new DBAdapter(this);   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pager);     
    Intent startCharacterViewer = getIntent();
    final int activePagerPage = startCharacterViewer.getIntExtra("activePagerPage", 0);
    MyPagerAdapter adapter = new MyPagerAdapter();
    ViewPager myPager = (ViewPager) findViewById(R.id.myfivepanelpager);
    myPager.setAdapter(adapter);
    myPager.setCurrentItem(activePagerPage); } 

private class MyPagerAdapter extends PagerAdapter {

    Intent startCharacterViewer = getIntent();
    final int activeCharacter = startCharacterViewer.getIntExtra("activeCharacter", 0);
    public int getCount() {
        return 5;          
    }

    public Object instantiateItem(View collection, int position) {
        db.open();
        LayoutInflater inflater = (LayoutInflater) collection.getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        String name = db.getAttribute(activeCharacter, 1);
        int level = Integer.valueOf(db.getAttribute(activeCharacter, 2));
        //repeats for many variables (106 total)
        db.close();
        View v = null;

        switch (position) {
        //case 0
        case 0:
            v = inflater.inflate(R.layout.details, null); 
            break;
        //case 1
        case 1:
            v = inflater.inflate(R.layout.features, null);
            break;
        //case 2    
        case 2:
            v = inflater.inflate(R.layout.summary, null); 
            TextView text1 = (TextView) v.findViewById(R.id.textViewName);
            text1.setText (name + "    level " + level + " " + characterClass);
            //repeats many times for more text views
            //many many buttons and text views defined here
        //case 3   
        case 3: 
            v = inflater.inflate(R.layout.skills, null);
            //more text views and buttons defined here

        case 4:
            v = inflater.inflate(R.layout.inventory, null);
            break;
        }



        ((ViewPager) collection).addView(v, 0);


        return v;
    }
</code></pre>

<p>Buttons and text view set code are nested inside the case areas of the instantiateItem.
Example of one of the buttons:</p>

<pre><code>            TextView hpUpdaterText1 = (TextView) v.findViewById(R.id.textViewHP);
            TextView hpUpdaterText2 = (TextView) v.findViewById(R.id.textViewSurges);
            final int a1 = hpMax;
            final int b1 = hpSurgeMax;
            View.OnClickListener hpModifierListener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    final Dialog myDialog = new Dialog(CharacterViewer.this);
                    myDialog.setContentView(R.layout.edithitpoints);
                    myDialog.setTitle("Modify Permanent Health Values");
                    myDialog.setCancelable(true);
                    myDialog.show();                    
                    EditText text1 = (EditText) myDialog.findViewById(R.id.editTextHPMax);
                    text1.setText ("" + (a1));                      
                    EditText text2 = (EditText) myDialog.findViewById(R.id.editTextSurges);
                    text2.setText ("" + (b1));
                    //Cancel button
                    Button button1 = (Button) myDialog.findViewById(R.id.editHitPointsCancel);
                    button1.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            myDialog.dismiss();
            }});
                    //OK button
                    Button button2 = (Button) myDialog.findViewById(R.id.editHitPointsOK);
                    button2.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            EditText text1 = (EditText) myDialog.findViewById(R.id.editTextHPMax);
                            String a = text1.getText().toString();
                            if( a.length() == 0 ) {text1.setError( "Value Required" );}
                            EditText text2 = (EditText) myDialog.findViewById(R.id.editTextSurges);
                            String b = text2.getText().toString();
                            if( b.length() == 0 ) {text2.setError( "Value Required" );}
                            if (a.length() != 0 &amp;&amp; b.length() != 0){
                            db.open();
                            db.updatePermanentHP(activeCharacter, a, b);                                
                            db.close();
                            //restart activity to update variables
                            Intent startCharacterViewer = new Intent("android.intent.action.SUMMARY");
                            startCharacterViewer.putExtra("activeCharacter", activeCharacter);
                            finish();
                            startCharacterViewer.putExtra("activePagerPage", 2);
                            startActivity(startCharacterViewer);
                            myDialog.dismiss();}
                            else {Toast msg = Toast.makeText(CharacterViewer.this,
                                    "Please enter a value for" + "\n" + "all available fields", Toast.LENGTH_SHORT);
                                    msg.show();;}
            }});
            }};
            hpUpdaterText1.setOnClickListener(hpModifierListener);
            hpUpdaterText2.setOnClickListener(hpModifierListener);
</code></pre>

<p>adding any code line anywhere as long as its inside the instantiateItem causes the error. For example I can cut and paste this block of code anywhere inside instantiateItem and it makes the program crash.  These variable names aren't used for anything.</p>

<p>example problem code block:</p>

<pre><code>        int uuu = 1;
        int aaa = 2;
        int bbb = 3;
        int ccc = 4;
        int ddd = 5;
        int eee = 6;
</code></pre>
