应用崩溃Android

时间:2018-03-05 17:07:36

标签: java android android-studio preferencescreen

每次尝试访问设置菜单时,我的应用都会崩溃。我正在通过udacity进行Android开发。我加载AVD时应用运行正常,并没有给我任何错误。我认为这与我如何设置菜单的xml或java活动有关。我尝试使用在课程中为我们提供的代码答案,但应用程序仍然崩溃。如果有人可以帮我解决这个问题,我真的很感激。我是android编程的新手。以下是与该应用相关联的文件。

这里是logcat

03-05 12:53:14.514 11791-11791/? I/art: Late-enabling -Xcheck:jni
03-05 12:53:14.551 11791-11797/? E/art: Failed sending reply to debugger: Broken pipe
03-05 12:53:14.551 11791-11797/? I/art: Debugger is no longer active
03-05 12:53:14.688 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:14.903 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:14.955 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.004 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.059 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.110 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.162 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.213 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.272 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.324 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.379 11791-11791/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.android.example.sunshineapp-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.android.example.sunshineapp-2@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
03-05 12:53:15.380 11791-11791/? W/System: ClassLoader referenced unknown path: /data/app/com.android.example.sunshineapp-2/lib/arm
03-05 12:53:15.398 11791-11791/? I/InstantRun: starting instant run server: is main process
03-05 12:53:15.401 11791-11791/? V/InstantRun: Starting server socket listening for package com.android.example.sunshineapp on android.net.LocalSocketAddress@75de48c
03-05 12:53:15.402 11791-11791/? V/InstantRun: Started server for package com.android.example.sunshineapp
03-05 12:53:15.628 11791-11791/com.android.example.sunshineapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-05 12:53:15.719 11791-11791/com.android.example.sunshineapp D/PhoneWindowEx: [PWEx][generateLayout] setLGNavigationBarColor : colors=0xffe9ebee
03-05 12:53:15.719 11791-11791/com.android.example.sunshineapp I/PhoneWindow: [setLGNavigationBarColor] color=0x ffe9ebee
03-05 12:53:15.949 11791-11791/com.android.example.sunshineapp D/MainActivity: onCreate: registering preference changed listener
03-05 12:53:15.994 11791-11885/com.android.example.sunshineapp D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: false
03-05 12:53:15.999 11791-11791/com.android.example.sunshineapp D/PhoneWindow: notifyNavigationBarColor, color=0x: ffe9ebee, token: android.view.ViewRootImplAO$WEx@f0a0e16
03-05 12:53:16.000 11791-11884/com.android.example.sunshineapp V/NetworkUtils: URL: https://andfun-weather.udacity.com/staticweather?q=Mountain%20View%2C%20CA%2094043&mode=json&units=metric&cnt=14
03-05 12:53:16.004 11791-11884/com.android.example.sunshineapp D/libc: skt_base:0, kt_base:0, mptcp_enabled:0, socks_enabled:0, wifi_connected:1
03-05 12:53:16.004 11791-11884/com.android.example.sunshineapp D/libc: skt_base:0, kt_base:0, mptcp_enabled:0, socks_enabled:0, wifi_connected:1
03-05 12:53:16.133 11791-11885/com.android.example.sunshineapp I/OpenGLRenderer: Initialized EGL, version 1.4
03-05 12:53:16.147 11791-11885/com.android.example.sunshineapp D/mali_winsys: new_window_surface returns 0x3000
03-05 12:53:16.188 11791-11791/com.android.example.sunshineapp W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
03-05 12:53:16.198 11791-11884/com.android.example.sunshineapp D/libc: skt_base:0, kt_base:0, mptcp_enabled:0, socks_enabled:0, wifi_connected:1
03-05 12:53:16.310 11791-11885/com.android.example.sunshineapp I/[MALI][Gralloc]: [+]r_hnd(0xb8314640), client(52), share_fd(50)
03-05 12:53:16.443 11791-11885/com.android.example.sunshineapp I/[MALI][Gralloc]: [+]r_hnd(0xb831cff0), client(52), share_fd(53)
03-05 12:53:16.451 11791-11885/com.android.example.sunshineapp I/[MALI][Gralloc]: [+]r_hnd(0xb840dbd8), client(52), share_fd(55)
03-05 12:53:17.142 11791-11791/com.android.example.sunshineapp I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@8436731 time:153533026
03-05 12:53:18.549 11791-11791/com.android.example.sunshineapp I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
03-05 12:53:18.633 11791-11791/com.android.example.sunshineapp I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
03-05 12:53:18.649 11791-11791/com.android.example.sunshineapp I/AudioManagerEx: AudioManagerEx created
03-05 12:53:18.781 11791-11791/com.android.example.sunshineapp I/ListPopupWindow: Could not find method setEpicenterBounds(Rect) on PopupWindow. Oh well.
03-05 12:53:18.926 11791-11885/com.android.example.sunshineapp D/mali_winsys: new_window_surface returns 0x3000
03-05 12:53:18.982 11791-11885/com.android.example.sunshineapp I/[MALI][Gralloc]: [+]r_hnd(0xb84d1348), client(52), share_fd(60)
03-05 12:53:19.027 11791-11885/com.android.example.sunshineapp I/[MALI][Gralloc]: [+]r_hnd(0xb83098c8), client(52), share_fd(62)
03-05 12:53:19.047 11791-11791/com.android.example.sunshineapp V/ViewRootImpl: Contents drawing finished : PopupWindow:1c994ca
03-05 12:53:19.054 11791-11885/com.android.example.sunshineapp I/[MALI][Gralloc]: [+]r_hnd(0xb7f94d18), client(52), share_fd(65)
03-05 12:53:19.710 11791-11791/com.android.example.sunshineapp I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
03-05 12:53:19.811 11791-11791/com.android.example.sunshineapp I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
03-05 12:53:19.880 11791-11791/com.android.example.sunshineapp D/[AOP]Intent: Intent Private Mode Enable
03-05 12:53:19.881 11791-11791/com.android.example.sunshineapp I/Timeline: Timeline: Activity_launch_request id:com.android.example.sunshineapp time:153535765
03-05 12:53:19.990 11791-11791/com.android.example.sunshineapp D/PhoneWindowEx: [PWEx][generateLayout] setLGNavigationBarColor : colors=0xffe9ebee
03-05 12:53:19.990 11791-11791/com.android.example.sunshineapp I/PhoneWindow: [setLGNavigationBarColor] color=0x ffe9ebee
03-05 12:53:20.057 11791-11791/com.android.example.sunshineapp D/AndroidRuntime: Shutting down VM
03-05 12:53:20.120 11791-11791/com.android.example.sunshineapp E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                 Process: com.android.example.sunshineapp, PID: 11791
                                                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.example.sunshineapp/com.android.example.sunshineapp.Settings}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2440)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500)
                                                                                     at android.app.ActivityThread.access$900(ActivityThread.java:163)
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362)
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5585)
                                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
                                                                                  Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
                                                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                                                                                     at com.android.example.sunshineapp.Settings.onCreate(Settings.java:23)
                                                                                     at android.app.Activity.performCreate(Activity.java:6279)
                                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
                                                                                     at android.app.ActivityThread.access$900(ActivityThread.java:163) 
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                     at android.os.Looper.loop(Looper.java:148) 
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5585) 
                                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
                                                                                  Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class fragment
                                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
                                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                                                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                                                                                     at com.android.example.sunshineapp.Settings.onCreate(Settings.java:23) 
                                                                                     at android.app.Activity.performCreate(Activity.java:6279) 
                                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393) 
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
                                                                                     at android.app.ActivityThread.access$900(ActivityThread.java:163) 
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                     at android.os.Looper.loop(Looper.java:148) 
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5585) 
                                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
                                                                                  Caused by: java.lang.IllegalStateException: Must specify preferenceTheme in theme
                                                                                     at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:211)
                                                                                     at android.support.v4.app.Fragment.performCreate(Fragment.java:2339)
                                                                                     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1377)
                                                                                     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1640)
                                                                                     at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1896)
                                                                                     at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3673)
                                                                                     at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
                                                                                     at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:338)
                                                                                     at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
                                                                                     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67)
                                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:754)
                                                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                                                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                                                                                     at com.android.example.sunshineapp.Settings.onCreate(Settings.java:23) 
                                                                                     at android.app.Activity.performCreate(Activity.java:6279) 
                                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393) 
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
                                                                                     at android.app.ActivityThread.access$900(ActivityThread.java:163) 
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                     at android.os.Looper.loop(Looper.java:148) 
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5585) 
                                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 

1 个答案:

答案 0 :(得分:1)

我认为你的问题显而易见。通常人们忘记在那里添加活动。在Udacity(我假设有一个Vizualizer应用程序)中有清单:

<activity
    android:name=".SettingsActivity"
    android:label="@string/action_settings"
    android:parentActivityName=".VisualizerActivity">
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".VisualizerActivity" />
</activity>