我是Android编程的新手,刚刚创建了我的第一个应用程序。这是一个简单的一个问题应用程序,以帮助我开始。我的问题是它在启动时崩溃了。
我的QuizActivity.java如下
package com.android.geoquiz;
public class QuizActivity extends ActionBarActivity {
private Button mTrueButton;
private Button mFalseButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
mTrueButton = (Button)findViewById(R.id.true_button);
mTrueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(QuizActivity.this, R.string.incorrect_toast, Toast.LENGTH_SHORT).show();
}
});
mFalseButton = (Button)findViewById(R.id.false_button);
mFalseButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(QuizActivity.this, R.string.correct_toast, Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.quiz, 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);
}
}
我的activity_quiz.xml如下 -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height = "wrap_content"
android:padding = "24dp"
android:text="@string/question_text" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/true_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/true_button" />
<Button
android:id="@+id/false_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/false_button" />
</LinearLayout>
编辑:抱歉,这是我的logcat输出
06-07 00:57:26.037: I/art(24412): Late-enabling -Xcheck:jni
06-07 00:57:26.106: E/art(24412): Failed to send JDWP packet APNM to debugger (-1 of 65): Broken pipe
06-07 00:57:26.107: E/art(24412): Failed sending reply to debugger: Broken pipe
06-07 00:57:26.108: I/art(24412): Debugger is no longer active
06-07 00:57:26.200: D/AndroidRuntime(24412): Shutting down VM
06-07 00:57:26.209: E/AndroidRuntime(24412): FATAL EXCEPTION: main
06-07 00:57:26.209: E/AndroidRuntime(24412): Process: com.android.geoquiz, PID: 24412
06-07 00:57:26.209: E/AndroidRuntime(24412): java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/appcompat/R$styleable;
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:118)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
06-07 00:57:26.209: E/AndroidRuntime(24412): at com.android.geoquiz.QuizActivity.onCreate(QuizActivity.java:20)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.app.Activity.performCreate(Activity.java:5990)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.app.ActivityThread.access$800(ActivityThread.java:151)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.os.Handler.dispatchMessage(Handler.java:102)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.os.Looper.loop(Looper.java:135)
06-07 00:57:26.209: E/AndroidRuntime(24412): at android.app.ActivityThread.main(ActivityThread.java:5254)
06-07 00:57:26.209: E/AndroidRuntime(24412): at java.lang.reflect.Method.invoke(Native Method)
06-07 00:57:26.209: E/AndroidRuntime(24412): at java.lang.reflect.Method.invoke(Method.java:372)
06-07 00:57:26.209: E/AndroidRuntime(24412): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
06-07 00:57:26.209: E/AndroidRuntime(24412): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
06-07 00:57:26.209: E/AndroidRuntime(24412): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.appcompat.R$styleable" on path: DexPathList[[zip file "/data/app/com.android.geoquiz-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
06-07 00:57:26.209: E/AndroidRuntime(24412): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-07 00:57:26.209: E/AndroidRuntime(24412): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-07 00:57:26.209: E/AndroidRuntime(24412): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
06-07 00:57:26.209: E/AndroidRuntime(24412): ... 17 more
06-07 00:57:26.209: E/AndroidRuntime(24412): Suppressed: java.lang.ClassNotFoundException: android.support.v7.appcompat.R$styleable
06-07 00:57:26.209: E/AndroidRuntime(24412): at java.lang.Class.classForName(Native Method)
06-07 00:57:26.209: E/AndroidRuntime(24412): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
06-07 00:57:26.209: E/AndroidRuntime(24412): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
06-07 00:57:26.209: E/AndroidRuntime(24412): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
06-07 00:57:26.209: E/AndroidRuntime(24412): ... 18 more
06-07 00:57:26.209: E/AndroidRuntime(24412): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
06-07 00:57:26.214: W/ActivityManager(754): Force finishing activity 1 com.android.geoquiz/.QuizActivity
06-07 00:57:26.265: I/OpenGLRenderer(754): Initialized EGL, version 1.4
06-07 00:57:26.730: W/ActivityManager(754): Activity pause timeout for ActivityRecord{f644f38 u0 com.android.geoquiz/.QuizActivity t673 f}
06-07 00:57:26.815: I/ActivityManager(754): Killing 16119:com.google.android.gms.unstable/u0a7 (adj 15): empty #17
06-07 00:57:27.743: W/ResourceType(1434): No package identifier when getting value for resource number 0x00000000
06-07 00:57:27.743: W/PackageManager(1434): Failure retrieving resources for com.android.geoquiz: Resource ID #0x0
06-07 00:57:28.510: W/TRThreadPoolExecutor(26821): Task "NotifyOnDoneFutureTask[log_attempted_searches_to_kansas]" is a x. Failures of FutureTask can not be detected and exceptions will not be propagated by the executor
06-07 00:57:29.209: D/WifiService(754): acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@183cc8c8}
06-07 00:57:29.211: E/WifiStateMachine(754): WifiStateMachine CMD_START_SCAN source 10007 txSuccessRate=2.07 rxSuccessRate=0.50 targetRoamBSSID=00:00:00:00:00:00 RSSI=-77
06-07 00:57:29.853: D/WifiService(754): releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@183cc8c8}