user3225797 user3225797 - 22 days ago 5
Android Question

FATAL EXCEPTION: main in android app

I am very new in developing an android app and programming in JAVA. I am trying to develop this app that I was in the understanding that at least will show me the user interface, but I keep getting the problem of a faltal exception: main?... can you please help me?

This is the activity main in xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:id="@+id/Lights"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/Lights"
android:textColor="@style/AppBaseTheme" />

<Button
android:id="@+id/SysOff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/BluetoothConn"
android:layout_alignParentBottom="true"
android:layout_marginBottom="24dp"
android:text="@string/SysOff" />

<Button
android:id="@+id/SysOn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/SysOff"
android:layout_alignLeft="@+id/SysOff"
android:text="@string/SysOn" />

<Button
android:id="@+id/DoorsOpen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/DoorsClose"
android:layout_alignLeft="@+id/DoorsClose"
android:onClick="DoorsOpen"
android:text="@string/DoorsOpen" />

<Button
android:id="@+id/DoorsClose"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/SysOn"
android:layout_alignLeft="@+id/SysOn"
android:layout_marginBottom="21dp"
android:onClick="DoorsClose"
android:text="@string/DoorsClose" />

<Button
android:id="@+id/BluetoothConn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Lights"
android:layout_below="@+id/Lights"
android:onClick="BTConnect"
android:text="@string/BluetoothConnect" />

<TextView
android:id="@+id/SysPwr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/SysOn"
android:layout_alignLeft="@+id/DoorsClose"
android:text="@string/SysPwr" />

<Button
android:id="@+id/lightsOff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/LightsOn"
android:layout_below="@+id/LightsOn"
android:onClick="LightsOff"
android:text="@string/LightsOff" />

<TextView
android:id="@+id/Doors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/DoorsOpen"
android:layout_alignRight="@+id/Lights"
android:text="@string/Doors"
android:textAppearance="@style/AppBaseTheme" />

<Button
android:id="@+id/LightsOn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/BluetoothConn"
android:layout_below="@+id/BluetoothConn"
android:layout_marginTop="18dp"
android:onClick="LightsOn"
android:text="@string/LightsOn" />

</RelativeLayout>


Here is the MainActivity.java:

package com.example.mustangsound;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

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

public void BTConnect (){

}

public void LightsOn (){

}

public void LightsOff (){

}

public void DoorsOpen (){

}

public void DoorsClose (){

}

public void SysOn (){

}

public void SysOff (){

}


@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;
}

}


Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mustangsound"
android:versionCode="1"
android:versionName="1.0"
android:name="android.permission.BLUETOOTH">

<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="18" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.mustangsound.MainActivity"
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>


And the LogCat:

01-25 05:30:28.128: W/dalvikvm(1902): threadid=1: thread exiting with uncaught exception (group=0xb4cf5908)
01-25 05:30:28.188: E/AndroidRuntime(1902): FATAL EXCEPTION: main
01-25 05:30:28.188: E/AndroidRuntime(1902): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mustangsound/com.example.mustangsound.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.os.Handler.dispatchMessage(Handler.java:99)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.os.Looper.loop(Looper.java:137)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-25 05:30:28.188: E/AndroidRuntime(1902): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 05:30:28.188: E/AndroidRuntime(1902): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 05:30:28.188: E/AndroidRuntime(1902): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-25 05:30:28.188: E/AndroidRuntime(1902): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-25 05:30:28.188: E/AndroidRuntime(1902): at dalvik.system.NativeStart.main(Native Method)
01-25 05:30:28.188: E/AndroidRuntime(1902): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
01-25 05:30:28.188: E/AndroidRuntime(1902): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-25 05:30:28.188: E/AndroidRuntime(1902): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.Activity.setContentView(Activity.java:1881)
01-25 05:30:28.188: E/AndroidRuntime(1902): at com.example.mustangsound.MainActivity.onCreate(MainActivity.java:12)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.Activity.performCreate(Activity.java:5104)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-25 05:30:28.188: E/AndroidRuntime(1902): ... 11 more
01-25 05:30:28.188: E/AndroidRuntime(1902): Caused by: java.lang.reflect.InvocationTargetException
01-25 05:30:28.188: E/AndroidRuntime(1902): at java.lang.reflect.Constructor.constructNative(Native Method)
01-25 05:30:28.188: E/AndroidRuntime(1902): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
01-25 05:30:28.188: E/AndroidRuntime(1902): ... 24 more
01-25 05:30:28.188: E/AndroidRuntime(1902): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f060000 a=-1 r=0x7f060000}
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.content.res.Resources.loadColorStateList(Resources.java:2074)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.widget.TextView.<init>(TextView.java:775)
01-25 05:30:28.188: E/AndroidRuntime(1902): at android.widget.TextView.<init>(TextView.java:449)
01-25 05:30:28.188: E/AndroidRuntime(1902): ... 27 more


Thanks for the help

Answer

Its probably caused by the line

android:textColor="@style/AppBaseTheme"

in your first TextView . It probably should be

android:textAppearance="@style/AppBaseTheme"

as in your last TextView