Hello-World-grade landscape Android app fails to start (complete code included)
- by WingedCat
I'm trying to develop a simple Android app, fixed in landscape mode. I am using Eclipse 1.3, compiling for Android SDK version 7 (OS version 2.1). When I try to run it in the emulator, it crashes on boot. (It gets as far as the unlock slider, but shortly after that when trying to launch the application itself, I get "The application Failtest (process com.wcs.failtest) has stopped unexpectedly. Please try again.".)
Here is main.xml (with the tags escaped so this displays properly):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="480px"
android:layout_height="320px"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="96px"
android:layout_height="320px"
android:id="@+id/action_menu"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="96px"
android:layout_height="48px"
>
<Button
android:layout_width="48px"
android:layout_height="48px"
android:background="#f00"
android:id="@+id/action_button_11"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Here is AndroidManifest.xml (again with the tags escaped so this displays properly):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wcs.failtest"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:name=".FailtestActivity"
android:screenOrientation="landscape"
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>
<uses-sdk android:minSdkVersion="7" />
</manifest>
And here is FailtestActivity.java:
package com.wcs.failtest;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.view.View.OnClickListener;
import android.view.View;
public class FailtestActivity extends Activity {
private OnClickListener action11Listener = new OnClickListener() {
public void onClick(View v) {
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button button;
button = (Button)findViewById(R.id.action_button_11);
button.setOnClickListener(action11Listener);
setContentView(R.layout.main);
}
}
I suspect it is something simple I'm overlooking. What is it?