我剛剛剛接觸到Android開發,我遵循Gradle新項目嚮導,並創建了一個導航抽屜應用程序。我在模擬器中運行它,它工作,但是當我在手機上運行它時,會拋出以下錯誤。我無法理解什麼是問題Android錯誤充氣課程片段
12-14 19:17:15.401 2917-2917/com.aalasolutions.pakblood E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aalasolutions.pakblood/com.aalasolutions.pakblood.MainActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1960)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1985)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4482)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
at android.app.Activity.setContentView(Activity.java:2096)
at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:111)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
at com.aalasolutions.pakblood.MainActivity.onCreate(MainActivity.java:37)
at android.app.Activity.performCreate(Activity.java:4728)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1051)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1924)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1985)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4482)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.aalasolutions.pakblood.MainActivity.onCreateOptionsMenu(MainActivity.java:82)
at android.app.Activity.onCreatePanelMenu(Activity.java:2707)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:224)
at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:232)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreatePanelMenu(ActionBarActivityDelegateICS.java:147)
at android.support.v7.app.ActionBarActivity.onCreatePanelMenu(ActionBarActivity.java:199)
at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onCreatePanelMenu(ActionBarActivityDelegateICS.java:285)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:399)
at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:750)
at android.app.Activity.invalidateOptionsMenu(Activity.java:2815)
at android.support.v4.app.ActivityCompatHoneycomb.invalidateOptionsMenu(ActivityCompatHoneycomb.java:29)
at android.support.v4.app.FragmentActivity.supportInvalidateOptionsMenu(FragmentActivity.java:648)
at android.support.v7.app.ActionBarActivity.supportInvalidateOptionsMenu(ActionBarActivity.java:170)
at android.support.v4.app.Fragment.setHasOptionsMenu(Fragment.java:803)
at com.aalasolutions.pakblood.NavigationDrawerFragment.onCreate(NavigationDrawerFragment.java:82)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1477)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:893)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
at android.view.Lay
這裏是我的清單文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aalasolutions.pakblood"
android:versionCode="1"
android:versionName="0.5.3" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.aalasolutions.pakblood.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>
編輯
反而顯示這裏的一切。我已經粘貼代碼下面的鏈接,
- src/main/java/com.aalasolutions.pakblood/MainActivity
- src/main/java/com.aalasolutions.pakblood/NavigationDrawerFragment
- src/main/res/layout/activity_main
但讓我再告訴你,我只是跟着嚮導,跑碼,無碼改變或編輯任何東西
你必須將XML和代碼的確切行.. –
檢查更新問題 –