[Android Q&A, Help & Troubleshooting] Marc.:
Hi,

I started following the 'Building your first app' on developer.android.com,

I like to do it but now after following the instructions fully it is crashing when you click the button.

I used as build platform Android 4.1, but that should not matter...

I included the codes down here, I hope anyone can help.

MyFirstActivity.java:

package com.example.lesson.one;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MyFirstActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.myapp.MESSAGE";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

// It crashes here, because here is the part where you push the button.
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}

}

DisplayMessageActivity.java:

package com.example.lesson.one;

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

public class DisplayMessageActivity extends Activity {

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MyFirstActivity.EXTRA_MESSAGE);

// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);

setContentView(textView);
}
}

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MJV.lesson.one"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MyFirstActivity"
android:label="@string/title_activity_my_first" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.myapp.DisplayMessageActivity" />
</application>

</manifest>

Strings.xml:

<resources>

<string name="app_name">Lesson ONE</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_my_first">MyFirstActivity</string>

<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>

</resources>

Main.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">

<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>

I hope anyone can help me... Because Eclipse isn't giving any errors...

Edit 1: I tried it again, now without any things in the new activity. ( I mean without any code it must do ).

It still crashes, so its somewhere where it will start the new activity.

Edit 2: I ran a logcat, but I know now it cant find DisplayMessageActivity in androidmanifest.xml... Though its already added.

Edit 3: I found my problem, it was in androidmanifest.xml. I stated DisplayMessageActivity wrong! I read too quickly and skipped that part...