我对最新的Android Wear版本(5.0.2)有疑问:
使用该版本调试应用程序确实非常痛苦,因为应用程序通常会在启动时(或之后不久)直接崩溃。启动的活动有多复杂/简单并不重要。通过语音命令启动活动会增加崩溃的可能性。
每次应用程序崩溃时,您都可以在日志中找到这些行(编辑:添加日志记录到活动生命周期方法):
04-16 17:22:15.830 1736-1771/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14000000 pkg=some.package.name cmp=some.package.name/.MainActivity} from uid 10003 on display 0
04-16 17:22:15.866 1422-1962/? D/mot_vr_audio_hw﹕ dsp_recognizer_enabled = true
04-16 17:22:15.866 1416-1416/? D/ADSPD﹕ Client cmd=0x0003, size=4
04-16 17:22:15.875 1422-1962/? E/audio_a2dp_hw﹕ adev_set_parameters: ERROR: set param called even when stream out is null
04-16 17:22:15.881 1422-1422/? D/mot_vr_audio_hw﹕ open_input_stream(): devices = 0x80000004, rate = 8000, channels = 0x10
04-16 17:22:15.881 1422-1422/? D/mot_vr_audio_hw﹕ Created resampler for 16000->8000 Hz
04-16 17:22:15.887 1416-1416/? D/ADSPD﹕ Received from DSP: cmd=0x8003, size=2
04-16 17:22:15.887 1416-1416/? D/ADSPD﹕ Client cmd=0x4003, size=2
04-16 17:22:15.892 1422-2055/? D/mot_vr_audio_hw﹕ received recognition control callback, status 0
04-16 17:22:15.898 1422-5214/? I/AudioFlinger﹕ AudioFlingers thread 0xb5a0b008 ready to run
04-16 17:22:15.924 1422-5214/? D/mot_vr_audio_hw﹕ in_read waiting for hotword
04-16 17:22:15.977 1895-1906/? I/art﹕ Background partial concurrent mark sweep GC freed 3006(429KB) AllocSpace objects, 0(0B) LOS objects, 24% free, 1752KB/2MB, paused 762us total 172.698ms
04-16 17:22:16.002 1736-1943/? I/MediaFocusControl﹕ AudioFocus abandonAudioFocus() from android.media.AudioManager@3de0633bcom.google.android.clockwork.speech.audio.AudioFocusManager$1@31686a58
04-16 17:22:16.023 1422-1664/? D/mot_vr_audio_hw﹕ dsp_recognizer_enabled = false
04-16 17:22:16.023 1416-1416/? D/ADSPD﹕ Client cmd=0x0003, size=4
04-16 17:22:16.033 1422-1664/? E/audio_a2dp_hw﹕ adev_set_parameters: ERROR: set param called even when stream out is null
04-16 17:22:16.045 1416-1416/? D/ADSPD﹕ Received from DSP: cmd=0x8003, size=2
04-16 17:22:16.050 1422-2055/? D/mot_vr_audio_hw﹕ received recognition control callback, status 0
04-16 17:22:16.055 1416-1416/? D/ADSPD﹕ Client cmd=0x0003, size=4
04-16 17:22:16.061 1422-5214/? D/mot_vr_audio_hw﹕ Switching DSP to standby/passthrough mode
04-16 17:22:16.061 1422-5214/? D/mot_vr_audio_hw﹕ Input 0xb88d8e08 ready to read
04-16 17:22:16.073 1416-1416/? D/ADSPD﹕ Received from DSP: cmd=0x8003, size=2
04-16 17:22:16.077 1422-2055/? D/mot_vr_audio_hw﹕ received recognition control callback, status 0
04-16 17:22:16.122 1422-5214/? D/mot_vr_audio_hw﹕ Discarded 10 buffers of leading silence
04-16 17:22:16.130 1416-1416/? D/ADSPD﹕ Client cmd=0x0003, size=4
04-16 17:22:16.136 1422-5214/? D/mot_vr_audio_hw﹕ Re-arming DSP
04-16 17:22:16.136 1422-5214/? D/mot_vr_audio_hw﹕ Input 0xb88d8e08 standby complete
04-16 17:22:16.145 1422-1422/? D/mot_vr_audio_hw﹕ Input 0xb88d8e08 close complete
04-16 17:22:16.148 1416-1416/? D/ADSPD﹕ Received from DSP: cmd=0x8003, size=2
04-16 17:22:16.149 1416-1416/? D/ADSPD﹕ Client cmd=0x4003, size=2
04-16 17:22:16.153 1422-2055/? D/mot_vr_audio_hw﹕ received recognition control callback, status 0
04-16 17:22:16.185 1736-1736/? V/ActivityManager﹕ Display changed displayId=0
04-16 17:22:16.330 1736-1963/? I/art﹕ Explicit concurrent mark sweep GC freed 15352(805KB) AllocSpace objects, 4(64KB) LOS objects, 19% free, 7MB/9MB, paused 1.708ms total 157.135ms
04-16 17:22:16.369 3499-3499/some.package.name D/MainActivity﹕ onCreate(), creating GoogleAPIs client and layout
04-16 17:22:16.419 1736-1943/? I/DisplayManagerService﹕ Display device added: DisplayDeviceInfo{"ActivityViewVirtualDisplay": 320 x 320, 60.0 fps, supportedRefreshRates [], density 213, 213.0 x 213.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, state OFF, owner android (uid 1000), FLAG_OWN_CONTENT_ONLY}
04-16 17:22:16.426 1736-1736/? V/ActivityManager﹕ Display added displayId=1
04-16 17:22:16.463 1736-1736/? V/ActivityManager﹕ Display changed displayId=1
04-16 17:22:16.505 1736-1963/? I/ActivityManager﹕ START u0 {flg=0x18010000 cmp=com.google.android.apps.fitness/com.google.android.wearable.fitness.notifications.NotificationGoalActivity (has extras)} from uid 10014 on display 1
04-16 17:22:16.589 1736-1943/? W/InputMethodManagerService﹕ Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@14011f8c attribute=null, token = android.os.BinderProxy@2747861f
04-16 17:22:16.685 3499-3499/some.package.name D/MainActivity﹕ onStart(), connecting to GoogleAPIs
04-16 17:22:16.685 3499-3499/some.package.name D/MainActivity﹕ onResume()
04-16 17:22:16.685 3499-3499/some.package.name D/MainActivity﹕ onPostResume()
04-16 17:22:16.843 3499-3499/some.package.name D/MainActivity﹕ connected to GoogleAPIs
04-16 17:22:16.944 1736-1763/? I/ActivityManager﹕ Displayed some.package.name/.MainActivity: +765ms
04-16 17:22:17.773 3499-3499/some.package.name D/ViewRootImpl﹕ changeCanvasOpacity: opaque=true
04-16 17:22:17.779 3499-3499/some.package.name D/MainActivity﹕ onStop(), disconnecting from GoogleAPIs
04-16 17:22:17.955 2217-5216/? D/OpenGLRenderer﹕ Render dirty regions requested: true
04-16 17:22:17.974 2217-2217/? D/Atlas﹕ Validating map...
04-16 17:22:18.057 2217-5216/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
04-16 17:22:18.057 2217-5216/? W/OpenGLRenderer﹕ Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
04-16 17:22:18.074 2217-5216/? D/OpenGLRenderer﹕ Enabling debug mode 0
04-16 17:22:18.257 1736-1763/? I/DisplayManagerService﹕ Display device changed: DisplayDeviceInfo{"ActivityViewVirtualDisplay": 320 x 320, 60.0 fps, supportedRefreshRates [], density 213, 213.0 x 213.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, state ON, owner android (uid 1000), FLAG_OWN_CONTENT_ONLY}
04-16 17:22:18.261 1736-1736/? V/ActivityManager﹕ Display changed displayId=1
04-16 17:22:18.282 1736-1763/? I/ActivityManager﹕ Displayed com.google.android.apps.fitness/com.google.android.wearable.fitness.notifications.NotificationGoalActivity: +584ms
04-16 17:22:19.849 1736-1799/? D/TaskPersister﹕ removeObsoleteFile: deleting file=779_task.xml
04-16 17:22:22.004 2137-2197/? W/bt-btif﹕ dm_pm_timer expires
04-16 17:22:22.004 2137-2197/? W/bt-btif﹕ dm_pm_timer expires 0
04-16 17:22:22.004 2137-2197/? W/bt-btif﹕ proc dm_pm_timer expires
04-16 17:22:25.273 2137-2197/? W/bt-btif﹕ dm_pm_timer expires
04-16 17:22:25.273 2137-2197/? W/bt-btif﹕ dm_pm_timer expires 0
04-16 17:22:25.274 2137-2197/? W/bt-btif﹕ proc dm_pm_timer expires
04-16 17:22:25.807 1736-1765/? I/PowerManagerService﹕ Going to sleep due to screen timeout (uid 1000)...
04-16 17:22:25.824 3499-3499/some.package.name E/ActivityThread﹕ Performing pause of activity that is not resumed: {some.package.name/some.package.name.MainActivity}
java.lang.RuntimeException: Performing pause of activity that is not resumed: {some.package.name/some.package.name.MainActivity}
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3196)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3184)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3159)
at android.app.ActivityThread.access$1000(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
04-16 17:22:25.824 3499-3499/some.package.name D/MainActivity﹕ onPause()
04-16 17:22:25.868 1736-1765/? I/DreamManagerService﹕ Entering dreamland.
04-16 17:22:25.868 1736-1765/? I/PowerManagerService﹕ Dozing...
04-16 17:22:25.880 3499-3499/some.package.name E/ActivityThread﹕ Performing stop of activity that is not resumed: {some.package.name/some.package.name.MainActivity}
java.lang.RuntimeException: Performing stop of activity that is not resumed: {some.package.name/some.package.name.MainActivity}
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3309)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3390)
at android.app.ActivityThread.access$1100(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
04-16 17:22:25.886 1736-1760/? I/DreamController﹕ Starting dream: name=ComponentInfo{com.google.android.wearable.app/com.google.android.clockwork.home.AmbientMode}, isTest=false, canDoze=true, userId=0
04-16 17:22:25.931 1736-1736/? E/InputMethodManagerService﹕ Ignoring setImeWindowStatus due to an invalid token. uid:1000 token:null
04-16 17:22:25.941 1736-1736/? E/InputMethodManagerService﹕ Ignoring setImeWindowStatus due to an invalid token. uid:1000 token:null
04-16 17:22:25.956 1736-1961/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.google.android.wearable.app/com.google.android.clockwork.home.HomeActivity (has extras)} from uid 10003 on display 0
有没有人知道这个bug的解决方案/解决方法?
提前致谢
答案 0 :(得分:1)
此漏洞已在Android Wear 5.1.1中修复。
答案 1 :(得分:0)
我认为这不是内存泄漏。如果收集器花费超过3秒的“收集”时间,您将识别具有OutOfMemoryExceptions或垃圾收集器转储的那些。
在这种情况下,您的日志指出应用程序崩溃是因为您暂停或停止未恢复的活动。你是不是偶然地打电话给onPause或onStop?