开发者

Why Android mobile is not running my application? [closed]

开发者_开发问答 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I am trying to run a simple program hello world in my android mobile. but the application stops unexpectedly. the apk file is installing easily but it is not running. I do not understand why this happens

helloWorld.java

package com.hellos;

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.TextView;

public class HelloAndroid extends Activity {    
 /** Called when the activity is first created. */    
 @Override    
       public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);    
 } 
 }


Follow the Hello World Tutorial

If you already are and have followed it correctly (emulator installed etc) then everything should be working.

I know this may sound odd, but if you are sure all was done right try copy and pasting your code into a new project and try launching it again. (Others have done this here on SO and it has worked.)

I have had errors like this in other things, and its usually something that the phone/emulator does not like for some reason (when I think everything should work). Try to dumb down (This will behard since its hello world) your xml etc, and see if you can get it to run.

Your code should look as follows

package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {   
/** Called when the activity is first created. */   
@Override   

public void onCreate(Bundle savedInstanceState) {      
 super.onCreate(savedInstanceState);       
TextView tv = new TextView(this);       
tv.setText("Hello, Android");       
setContentView(tv);   }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜