Question

I modified my main.xml and my android app crashed.

I run debugger and find it threw a RuntimeException in

ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663

I can't understand where the bug is in my program. I bisected the code, and find this line threw it:

giveUpButton = (Button) findViewById(R.id.GiveUpButton);

I'm sure because the exception disappeared after I removed this line.

I have no any idea. Why isn't the top of stack findViewById? Why does it throw exception?

I have this code in main.xml:

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/give_up_button"
android:id="@+id/GiveUpButton"/>  
Was it helpful?

Solution

I know it sounds like a joke. But I have fixed the problem by... restarting my Eclipse.

It's very likely caused by Git's checkout. I switch between branches without closing Eclipse.

How can I avoid such a problem? It cost a lot of time to restart Eclipse over and over again.

OTHER TIPS

did you

setContentView(R.layout.main) 

before the line

giveUpButton = (Button)findViewById(R.id.GiveUpButton);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top