java.lang.RuntimeException: Unable to start activity ComponentInfo

Br4ve

Bekanntes Mitglied
Hi,
ich bin grade in die Androidprogrammierung eingestiegen und war dabei eine erste App zu erstellen. Leider bekomme ich dauernd einen Fehler, den ich trotz Google und Forensuche einfach nicht behoben kriege. Die relevante Fehlermeldung von LogCat lautet wie folgt:
Code:
12-28 17:00:08.895: E/AndroidRuntime(5450): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.muckenmassaker/com.example.muckenmassaker.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
12-28 17:00:08.895: E/AndroidRuntime(5450): 	at com.example.muckenmassaker.MainActivity.onCreate(MainActivity.java:16)
Die beiden Abschnitte auf die hier verwiesen wird lauten:
[XML]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@dimen/activity_horizontal_margin"
android:gravity="center"
android😛addingBottom="@dimen/activity_vertical_margin"
android😛addingLeft="@dimen/activity_horizontal_margin"
android😛addingRight="@dimen/activity_horizontal_margin"
android😛addingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="false"
android:layout_centerInParent="false"
android:layout_centerVertical="false"
android:gravity="center"
android:text="@string/beschriftung"
android:textColor="@dimen/activity_horizontal_margin"
android:textSize="20sp" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="@string/start" />

</RelativeLayout>[/XML]

Und die Javaklasse:
Java:
package com.example.muckenmassaker;

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

public class MainActivity extends Activity implements OnClickListener{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Button button = (Button) findViewById(R.id.button1);
		button.setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		startActivity(new Intent(this,GameActivity.class));
		
	}

}
Befindet sich dort irgendwo ein offensichtlicher Fehler?
 
Hallo,

in Deinem TextView macht [XML]android:textColor="@dimen/activity_horizontal_margin"[/XML] schon einmal keinen Sinn. Ansonsten hab ich nix gesehen.

Ansonsten: schau ob alle @ Ressourcen vorhanden bzw richtig angegeben sind.
Geh von Schritt zu Schritt vor, um den Fehler zu finden: Lösch die Views, schau ob das RelativeLayout passt. Und dann setz die Views ein und schau, welches nicht stimmt. Danach schau, an welchem Attribut es liegt.

Gruß
 
...und wenn du alles wie angemerkt überprüft/verbessert hast, cleane die App am besten mal! Manchmal hab ich in Eclipse schon komische Effekte gehabt, wenn ich schnell was geändert und gleich die App auf ein Telefon zu debuggen gepusht hab.
 

Zurück
Oben