2

I have a very very strange issue, and i believe my elcipse juno is broken. I have the Android ADT plugin in this eclipse.

The following screenshot will prove my believe.

enter image description here

And its not finished yet. After the screenshot above, i press F6 again, and this is what i got :

enter image description here

I will explain this case once again to make a clear question. I debug my application, then i got that the arg2 value is 1. After that, i press f6 and the code goes to case 0 (instead of case 1) and then i press f6 again and the code goes to case 6 (WTF????? i do have a break, how come it comes to case 0 and case 6?)

In case you need it, this is the code in the above screenshots :

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        // TODO Auto-generated method stub
        Intent i = new Intent(this, Chapter.class);

        switch(arg2)
        {
        case 0:
            Toast.makeText(this, "a", Toast.LENGTH_SHORT).show();
            break;
        case 1:
            i.putExtra("key", 1);
            Toast.makeText(this, arg2 , Toast.LENGTH_SHORT).show();
            startActivity(i);
            break;
        case 2:
            i.putExtra("key", 2);
            startActivity(i);
            break;
        case 3:
            i.putExtra("key", 3);
            startActivity(i);
            break;
        case 4:
            i.putExtra("key", 4);
            startActivity(i);
            break;
        case 5:
            i.putExtra("key", 5);
            startActivity(i);
            break;
        case 6:
            i.putExtra("key", 6);
            startActivity(i);
            break;
        case 7:
            i.putExtra("key", 7);
            startActivity(i);
            break;
        case 8:
            i.putExtra("key", 8);
            startActivity(i);
            break;
        }
    }

Thank you very much, and any help is appreciated.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Blaze Tama
  • 10,828
  • 13
  • 69
  • 129
  • Suggestion use activity context Intent i = new Intent(ActivityName.this, Chapter.class); Use activity context for displaying toast also – Raghunandan Jun 02 '13 at 14:26
  • Quick test project on my Juno (ADT Plugin only) shows totally correct behavior of debugger. Do you try to clean your project? (probably yes but it's better to clarify) – Viacheslav Jun 02 '13 at 17:40
  • @Raghunandan Thanks for your suggestion. It has no effect :D – Blaze Tama Jun 03 '13 at 00:22
  • @IdanAdar Unfortunately, i cant remove worklight because i will need it shortly – Blaze Tama Jun 03 '13 at 00:22
  • @Vyacheslav not yet (for the latest version of code),i will let you know after i tried it. – Blaze Tama Jun 03 '13 at 00:26
  • @Vyacheslav talking about cleaning project, i have a weird experience the last time i clean THIS project. Theres no error before cleaning, however the eclipse give me "R" error after cleaning. This is a very common error and i have faced it many times, but this time the error is UNFIXABLE (i have tried all i know), so i decided to copy a fresh project from my backup. Do you think its related? – Blaze Tama Jun 03 '13 at 00:32
  • @BlazeTama think no - missing R.java it's really common problem and there are at least two reasons why it happens: 1) Error somewhere in *.xml file (lint can help to found it) 2) Import android.R instead yourproject.R. Also if you have updated Android SDK to version 22 check that Android BuildTools installed. – Viacheslav Jun 03 '13 at 06:12
  • @Vyacheslav just want to inform you that its because a bug in the ADT 22, please see my answer. Thanks very much for your help :D – Blaze Tama Jun 03 '13 at 15:20

2 Answers2

1

I could be completely wrong, but this seems normal to me. The cases work like arrays where the first instance is 0 where your arg2 is an int so the first instance is 1

Ryan Sayles
  • 3,389
  • 11
  • 56
  • 79
  • Thanks for your help. But, arg2 is an int, not an array. And what should i do to get rid of this error? – Blaze Tama Jun 03 '13 at 00:26
  • Yeah I said arg2 is an int. The cases work like an array. Is your program actually throwing an error or are you just not getting the result you want? – Ryan Sayles Jun 03 '13 at 11:49
  • You might just have to change your code a little then (based on the parts you provided). But everything looks ok to me – Ryan Sayles Jun 03 '13 at 12:36
  • Thanks for your help. No need to change the code, it was a bug in ADT 22. Please see my answer. Thanks :D – Blaze Tama Jun 03 '13 at 15:21
1

YES, it is broken because of the bug in ADT 22. I need to upgrade the ADT to latest version and install Android Build Tools. After that, the program and the debugging runs NORMALLY.

Those are the links that may help you if you encounter a same problem with me :

https://groups.google.com/forum/?fromgroups#!topic/android-developers/rCaeT3qckoE https://groups.google.com/forum/?fromgroups=#!topic/adt-dev/epOfZbKPFdk

Blaze Tama
  • 10,828
  • 13
  • 69
  • 129