Reputation: 553
I am not totally new to working with the eclipse android plugin but I am new at writing a project from the ground up. So I went to the Android developers website to follow the 'Hello World' tutorial.
When I run my program the emulator puts up a screen that says unfortunately Hello, Android Has stopped working. my code is:
HelloAndroid.Java
package daniel.android.projects;
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Object o = null;
o.toString();
setContentView(R.layout.main);
}
}
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello"/>
Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello, Android! I am a string resource!</string>
<string name="app_name">Hello, Android</string>
</resources>
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="daniel.android.projects"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".AndroidTesterActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 0
Views: 247
Reputation: 137282
You have a null pointer exception, you assign null
to o
and then call toString()
on it:
Object o = null;
o.toString();
It seems like it serves nothing in your application anyway, it shouldn't be there.
Also, looking at your code, you create HelloAndroid
class, but in themanifest you declare
android:name=".AndroidTesterActivity"
it should be
android:name=".HelloAndroid"
Upvotes: 1