我无法启动此应用程序。这是我书中的教程。据我所知,它与ActionBarActivity
有关。如果需要任何其他信息,我将提供。
02-08 01:53:20.416: E/AndroidRuntime(812): FATAL EXCEPTION: main
02-08 01:53:20.416: E/AndroidRuntime(812): java.lang.RuntimeException: Unable to start activity
ComponentInfo{net.jthomas.concerttickets/net.jthomas.concerttickets.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
02-08 01:53:20.416: E/AndroidRuntime(812): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.os.Handler.dispatchMessage(Handler.java:99)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.os.Looper.loop(Looper.java:137)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.app.ActivityThread.main(ActivityThread.java:5103)
02-08 01:53:20.416: E/AndroidRuntime(812): at java.lang.reflect.Method.invokeNative(Native Method)
02-08 01:53:20.416: E/AndroidRuntime(812): at java.lang.reflect.Method.invoke(Method.java:525)
02-08 01:53:20.416: E/AndroidRuntime(812): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-08 01:53:20.416: E/AndroidRuntime(812): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-08 01:53:20.416: E/AndroidRuntime(812): at dalvik.system.NativeStart.main(Native Method)
02-08 01:53:20.416: E/AndroidRuntime(812): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
02-08 01:53:20.416: E/AndroidRuntime(812): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
02-08 01:53:20.416: E/AndroidRuntime(812): at net.jthomas.concerttickets.MainActivity.onCreate(MainActivity.java:23)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.app.Activity.performCreate(Activity.java:5133)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-08 01:53:20.416: E/AndroidRuntime(812): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
02-08 01:53:20.416: E/AndroidRuntime(812): ... 11 more
这是我项目的screenshot。
感谢您的帮助。
答案 0 :(得分:3)
如果ActionBarActivity出现问题并且您不打算使用操作栏,则可以将extends ActionBarActivity
替换为extends Activity
如果您需要操作栏,请将android:theme="@style/Theme.AppCompat.Light"
添加到AndroidManifest.xml
文件中的活动代码。