I am a beginner and have been using treehouse to learn. I am very early in the course and suddenly started getting a crash message when I start the app. I am unsure what is happening. I have posted everything that I know of. Sorry if I missed something or posted too much.
Main:
package com.example.crystalball;
import android.R.string;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
private CrystalBall mCrystalBall = new CrystalBall();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Declare our View variables
final TextView answerLabel = (TextView) findViewById(R.id.textView1);
Button getAnswerButton = (Button) findViewById(R.id.button1);
getAnswerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String answer = mCrystalBall.getAnAnswer();
// Update label with dynamic answer
answerLabel.setText(answer);
}
});
}
@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 boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
CrystalBall:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.crystalball"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name="com.example.crystalball.MainActivity"
android:label="@string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.crystalball"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name="com.example.crystalball.MainActivity"
android:label="@string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Logcat:
07-28 01:50:31.530: D/AndroidRuntime(980): Shutting down VM
07-28 01:50:31.530: W/dalvikvm(980): threadid=1: thread exiting with uncaught exception (group=0xb1ae7ba8)
07-28 01:50:31.570: E/AndroidRuntime(980): FATAL EXCEPTION: main
07-28 01:50:31.570: E/AndroidRuntime(980): Process: com.example.crystalball, PID: 980
07-28 01:50:31.570: E/AndroidRuntime(980): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.crystalball/com.example.crystalball.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.os.Handler.dispatchMessage(Handler.java:102)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.os.Looper.loop(Looper.java:136)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.main(ActivityThread.java:5017)
07-28 01:50:31.570: E/AndroidRuntime(980): at java.lang.reflect.Method.invokeNative(Native Method)
07-28 01:50:31.570: E/AndroidRuntime(980): at java.lang.reflect.Method.invoke(Method.java:515)
07-28 01:50:31.570: E/AndroidRuntime(980): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-28 01:50:31.570: E/AndroidRuntime(980): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-28 01:50:31.570: E/AndroidRuntime(980): at dalvik.system.NativeStart.main(Native Method)
07-28 01:50:31.570: E/AndroidRuntime(980): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
07-28 01:50:31.570: E/AndroidRuntime(980): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
07-28 01:50:31.570: E/AndroidRuntime(980): at com.example.crystalball.MainActivity.onCreate(MainActivity.java:16)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.Activity.performCreate(Activity.java:5231)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
07-28 01:50:31.570: E/AndroidRuntime(980): ... 11 more
07-28 01:50:37.070: I/Process(980): Sending signal. PID: 980 SIG: 9