문제

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"/>  
도움이 되었습니까?

해결책

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.

다른 팁

did you

setContentView(R.layout.main) 

before the line

giveUpButton = (Button)findViewById(R.id.GiveUpButton);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top