我们使用Mono for Android开发了一个App,发现在某些机型上(比如lenovo A3000-H)会打开会出现一直黑屏的情况,进不到程序的界面(同样也定位不到任何调试断点),而有些机型则不会。
通过仔细观察,发现在后台“当前运行程序”一栏,当成功启动时,程序所占体积是21mb左右。当启动失败时(一直黑屏),程序所占体积是9mb左右。
另外通过eclipse监控程序启动日志,对比发现了一些不同。
成功启动时的日志
02-24 16:00:47.038: I/ActivityManager(515): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.GDSCP.ModileEnforces/mobileenforces.BeginActivity} from pid 1016 02-24 16:00:47.073: W/Trace(515): 02-24 16:00:47.078: I/BufferQueue(133): [unnamed-133-2248](this:0x41f5b448,api:0) BufferQueue 02-24 16:00:47.078: I/BufferQueue(133): [unnamed-133-2248](this:0x41f5b448,api:0) consumerConnect 02-24 16:00:47.078: I/BufferQueue(133): [unnamed-133-2248](this:0x41f5b448,api:0) setConsumerName: unnamed-133-2248 02-24 16:00:47.078: I/SurfaceTexture(133): [unnamed-133-2248](this:0x41f5e5e8,api:0) SurfaceTexture 02-24 16:00:47.078: I/BufferQueue(133): [unnamed-133-2248](this:0x41f5b448,api:0) setSynchronousMode: enabled=1 02-24 16:00:47.078: I/BufferQueue(133): [unnamed-133-2248](this:0x41f5b448,api:0) setDefaultBufferSize: w=1, h=1 02-24 16:00:47.078: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f5b448,api:0) setConsumerName: Starting com.GDSCP.ModileEnforces 02-24 16:00:47.080: W/Trace(515): 02-24 16:00:47.085: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f5b448,api:0) setDefaultBufferSize: w=1024, h=552 02-24 16:00:47.088: W/Trace(515): 02-24 16:00:47.093: E/Launcher(1016): new onSaveInstanceState <F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2> 02-24 16:00:47.094: E/Launcher(1016): onPause flag orientation falg =2 02-24 16:00:47.097: W/Trace(515): 02-24 16:00:47.109: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f5b448,api:0) connect: api=2 02-24 16:00:47.109: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f5b448,api:2) setSynchronousMode: enabled=1 02-24 16:00:47.109: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f5b448,api:2) new GraphicBuffer needed 02-24 16:00:47.113: I/GraphicBuffer(133): allocate buffer (w:1024 h:552 f:1) err(0) 02-24 16:00:47.115: I/ActivityManager(515): Start proc com.GDSCP.ModileEnforces for activity com.GDSCP.ModileEnforces/mobileenforces.BeginActivity: pid=2225 uid=10106 gids={50106, 3003, 1015, 1028} 02-24 16:00:47.117: W/Trace(515): 02-24 16:00:47.117: W/Trace(515): 02-24 16:00:47.118: I/BufferQueue(133): [NEW] gb=0x41f63690, handle=0x41f63090, w=1024, h=552, s=1024, fmt=1 02-24 16:00:47.125: W/Trace(515): 02-24 16:00:47.135: I/SurfaceTexture(133): [Starting com.GDSCP.ModileEnforces](this:0x41f5e5e8,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)] 02-24 16:00:47.138: W/Trace(1016): /////////////////////// 02-24 16:00:47.150: I/com.umeng.common.b(1016): Could not get location from GPS or Cell-id, lack ACCESS_COARSE_LOCATION or ACCESS_COARSE_LOCATION permission? 02-24 16:00:47.160: W/Trace(2225): 02-24 16:00:47.160: W/Trace(2225): 02-24 16:00:47.167: W/ADB_SERVICES(2431): create_local_service_socket() name=jdwp:2225 02-24 16:00:47.168: W/ADB_SERVICES(2431): looking for pid 2225 in JDWP process list return fds0(18) fds1(20) 02-24 16:00:47.168: W/ADB_SERVICES(2431): trying to write to JDWP socket=16 pid=2225 count=1 out_fds=20 02-24 16:00:47.182: W/Trace(515): 02-24 16:00:47.184: W/Trace(515): 02-24 16:00:47.184: I/WindowManager(515): Losing focus: Window{41b51e38 u0 com.lenovo.launcher/com.lenovo.launcher2.Launcher} 02-24 16:00:47.184: W/Trace(515): 02-24 16:00:47.205: W/Trace(515): 02-24 16:00:47.214: I/ActivityThread(2225): Pub com.GDSCP.ModileEnforces.mono.MonoRuntimeProvider.__mono_init__: mono.MonoRuntimeProvider 02-24 16:00:47.218: W/MonoDroid-Debugger(2225): Not starting the debugger as the timeout value has been reached; current-time: 1393228847 timeout: 1392886499 02-24 16:00:47.227: E/mono(2225): WARNING: The runtime version supported by this application is unavailable. 02-24 16:00:47.229: E/mono(2225): Using default runtime: v2.0.50727 02-24 16:00:47.242: I/SurfaceTextureClient(133): [STC::queueBuffer] (this:0x41ad6840) fps:0.19, dur:69222.88, max:69032.22, min:5.73 02-24 16:00:47.242: I/SurfaceTextureClient(133): [STC::queueBuffer] this:0x41ad6840, api:1, last queue time elapsed:69032.22 02-24 16:00:47.242: I/BufferQueue(133): [FramebufferSurface](this:0x41ad9008,api:1) [release] fps:0.19, dur:69222.92, max:69032.27, min:5.69 02-24 16:00:47.242: I/BufferQueue(133): [FramebufferSurface](this:0x41ad9008,api:1) [queue] fps:0.19, dur:69222.87, max:69032.27, min:5.61 02-24 16:00:47.250: W/libc(2225):<span style="color: #FF0000;"> WARNING: generic atexit() called from legacy shared library 02-24 16:00:47.263: W/monodroid-gc(2225): GREF GC Threshold: 46800</span> 02-24 16:00:47.521: W/Trace(515): 02-24 16:00:47.531: W/Trace(515): <span style="color: #FF0000;">02-24 16:00:47.618: I/AppCheck(3425): oldcom.lenovo.launcher------------new:com.GDSCP.ModileEnforces 02-24 16:00:47.618: I/AppCheck(3425): runningTask------------action:com.lenovo.safecenter.activityswitch com.GDSCP.ModileEnforces com.lenovo.launcher 02-24 16:00:47.621: W/Trace(3425): 02-24 16:00:47.621: I/LeemCenterReceiver(3425): onReceive() 02-24 16:00:47.622: I/AppCheck(3425): runningTask------------end 02-24 16:00:47.623: I/AppCheck(3425): recentTask------------action:com.lenovo.safecenter.activityswitch2 com.GDSCP.ModileEnforces com.lenovo.launcher 02-24 16:00:47.625: I/AppCheck(3425): recentTask------------end 02-24 16:00:47.626: I/LeemCenterReceiver(3425): newPkg interval == 1393228847625 02-24 16:00:47.626: I/LeemCenterReceiver(3425): cur == 1393228847626 bootTime == 0 time == 1393228847625 02-24 16:00:47.628: W/Trace(3425): 02-24 16:00:47.628: W/Trace(3425): 02-24 16:00:47.628: I/ydp(3425): pkg---->com.GDSCP.ModileEnforces 02-24 16:00:47.628: E/ydp(3425): checkApp pkgName:com.GDSCP.ModileEnforces 02-24 16:00:47.640: I/safepaymen(3425): clearNotify Pkg:com.lenovo.launcher 02-24 16:00:47.647: W/Trace(3425): 02-24 16:00:47.647: W/Trace(3425): 02-24 16:00:47.649: W/Trace(3425): ////启动失败的顺序排位不同了 //先创建实例,再启动。而启动失败,则是先启动,再创建实例。 02-24 16:00:47.671: E/Launcher(1016): onTriMM<F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2> 02-24 16:00:47.671: E/AppsCustomizeTabHost(1016): onTrimMemory reset 000000000000000000000097777766666666111111</span> 02-24 16:00:47.697: W/Parcel(515): Attempt to read object from Parcel 0x57357554 at offset 68 that is not in the object list 02-24 16:00:47.810: I/BufferQueue(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f68008,api:1) disconnect: api=1 02-24 16:00:47.810: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher] [virtual android::status_t android::SurfaceTexture::forceAuxConversionLocked()] mCurrentTexture:1, mCurrentBuf:0x41f874f8 02-24 16:00:47.810: I/BufferQueue(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f68008,api:0) getReleasedBuffers: returning mask 0xffffffff 02-24 16:00:47.810: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41e38b58,api:0) destroying EGLImage dpy=0x1 img=0x41e38950 02-24 16:00:47.811: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41e38b58,api:0) destroying EGLImage dpy=0x1 img=0x4203c270 02-24 16:00:47.811: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41e38b58,api:0) destroying EGLImage dpy=0x1 img=0x41f877b8 02-24 16:00:47.812: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41e38b58,api:0) destroying EGLImage dpy=0x1 img=0x41f7cab8 02-24 16:00:47.818: I/mono-stdout(2225): 02-24 16:00:47.836: I/mono-stdout(2225): 16:00:47 | info | >>>Initialize the database>>>> 02-24 16:00:47.836: I/mono-stdout(2225): //启动成功了调用对应的输出 ......其后略
启动失败时的日志
02-24 16:04:07.855: W/Trace(515): 02-24 16:04:07.855: W/Trace(515): 02-24 16:04:07.856: I/ActivityManager(515): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.GDSCP.ModileEnforces/mobileenforces.BeginActivity} from pid 1016 02-24 16:04:07.893: W/Trace(515): //启动程序 02-24 16:04:07.895: W/Trace(515): 02-24 16:04:07.962: I/BufferQueue(133): [unnamed-133-2269](this:0x41f68008,api:0) BufferQueue 02-24 16:04:07.962: I/BufferQueue(133): [unnamed-133-2269](this:0x41f68008,api:0) consumerConnect 02-24 16:04:07.962: I/BufferQueue(133): [unnamed-133-2269](this:0x41f68008,api:0) setConsumerName: unnamed-133-2269 02-24 16:04:07.962: I/SurfaceTexture(133): [unnamed-133-2269](this:0x41f5eb38,api:0) SurfaceTexture 02-24 16:04:07.962: I/BufferQueue(133): [unnamed-133-2269](this:0x41f68008,api:0) setSynchronousMode: enabled=1 02-24 16:04:07.962: I/BufferQueue(133): [unnamed-133-2269](this:0x41f68008,api:0) setDefaultBufferSize: w=1, h=1 02-24 16:04:07.962: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f68008,api:0) setConsumerName: Starting com.GDSCP.ModileEnforces 02-24 16:04:07.963: W/Trace(515): 02-24 16:04:07.968: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f68008,api:0) setDefaultBufferSize: w=1024, h=552 02-24 16:04:07.971: W/Trace(515): 02-24 16:04:07.982: E/Launcher(1016): new onSaveInstanceState <F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2> 02-24 16:04:07.983: E/Launcher(1016): onPause flag orientation falg =2 02-24 16:04:07.987: W/Trace(515): 02-24 16:04:07.989: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f68008,api:0) connect: api=2 02-24 16:04:07.989: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f68008,api:2) setSynchronousMode: enabled=1 02-24 16:04:07.989: I/BufferQueue(133): [Starting com.GDSCP.ModileEnforces](this:0x41f68008,api:2) new GraphicBuffer needed 02-24 16:04:07.993: I/GraphicBuffer(133): allocate buffer (w:1024 h:552 f:1) err(0) 02-24 16:04:07.993: I/BufferQueue(133): [NEW] gb=0x41e38f58, handle=0x41f654a0, w=1024, h=552, s=1024, fmt=1 02-24 16:04:08.001: I/SurfaceTexture(133): [Starting com.GDSCP.ModileEnforces](this:0x41f5eb38,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)] 02-24 16:04:08.004: W/Trace(515): //////////////////////// 02-24 16:04:08.007: W/Trace(515): 02-24 16:04:08.026: I/ActivityManager(515): Start proc com.GDSCP.ModileEnforces for activity com.GDSCP.ModileEnforces/mobileenforces.BeginActivity: pid=2628 uid=10106 gids={50106, 3003, 1015, 1028} 02-24 16:04:08.026: W/Trace(515): 02-24 16:04:08.032: I/com.umeng.common.b(1016): Could not get location from GPS or Cell-id, lack ACCESS_COARSE_LOCATION or ACCESS_COARSE_LOCATION permission? 02-24 16:04:08.034: W/Trace(1016): 02-24 16:04:08.035: W/ADB_SERVICES(2431): create_local_service_socket() name=jdwp:2628 02-24 16:04:08.035: W/ADB_SERVICES(2431): looking for pid 2628 in JDWP process list return fds0(19) fds1(20) 02-24 16:04:08.035: W/ADB_SERVICES(2431): trying to write to JDWP socket=18 pid=2628 count=1 out_fds=20 02-24 16:04:08.075: W/Trace(515): 02-24 16:04:08.076: I/WindowManager(515): Losing focus: Window{41b51e38 u0 com.lenovo.launcher/com.lenovo.launcher2.Launcher} 02-24 16:04:08.076: W/Trace(515): 02-24 16:04:08.096: W/Trace(2628): 02-24 16:04:08.107: I/ActivityThread(2628): Pub com.GDSCP.ModileEnforces.mono.MonoRuntimeProvider.__mono_init__: mono.MonoRuntimeProvider 02-24 16:04:08.114: W/MonoDroid-Debugger(2628): Not starting the debugger as the timeout value has been reached; current-time: 1393229048 timeout: 1392886499 02-24 16:04:08.123: E/mono(2628): WARNING: The runtime version supported by this application is unavailable. 02-24 16:04:08.124: E/mono(2628): Using default runtime: v2.0.50727 02-24 16:04:08.125: I/SurfaceTextureClient(133): [STC::queueBuffer] (this:0x41ad6840) fps:1.56, dur:8327.26, max:8133.24, min:10.24 02-24 16:04:08.125: I/SurfaceTextureClient(133): [STC::queueBuffer] this:0x41ad6840, api:1, last queue time elapsed:8133.24 02-24 16:04:08.125: I/BufferQueue(133): [FramebufferSurface](this:0x41ad9008,api:1) [release] fps:1.56, dur:8327.23, max:8133.28, min:10.23 02-24 16:04:08.125: I/BufferQueue(133): [FramebufferSurface](this:0x41ad9008,api:1) [queue] fps:1.56, dur:8327.18, max:8133.29, min:10.23 02-24 16:04:08.144: W/libc(2628): WARNING: generic atexit() called from legacy shared library 02-24 16:04:08.160: W/monodroid-gc(2628): GREF GC Threshold: 46800 //启动 02-24 16:04:08.401: E/Launcher(1016): onTriMM<F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2><F2> 02-24 16:04:08.401: E/AppsCustomizeTabHost(1016): onTrimMemory reset 000000000000000000000097777766666666111111 02-24 16:04:08.403: W/Trace(515): 02-24 16:04:08.410: W/Trace(1016): 02-24 16:04:08.542: I/BufferQueue(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f5b448,api:1) disconnect: api=1 02-24 16:04:08.542: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher] [virtual android::status_t android::SurfaceTexture::forceAuxConversionLocked()] mCurrentTexture:1, mCurrentBuf:0x41f63918 02-24 16:04:08.542: I/BufferQueue(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f5b448,api:0) getReleasedBuffers: returning mask 0xffffffff 02-24 16:04:08.542: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f8b620,api:0) destroying EGLImage dpy=0x1 img=0x41f4c200 02-24 16:04:08.543: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f8b620,api:0) destroying EGLImage dpy=0x1 img=0x4203c270 02-24 16:04:08.543: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f8b620,api:0) destroying EGLImage dpy=0x1 img=0x41f7c6a0 02-24 16:04:08.544: I/SurfaceTexture(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f8b620,api:0) destroying EGLImage dpy=0x1 img=0x41f877b8 02-24 16:04:08.553: I/BufferQueue(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f5b448,api:0) consumerDisconnect 02-24 16:04:08.553: I/BufferQueue(133): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41f5b448,api:0) ~BufferQueue 02-24 16:04:08.567: W/Parcel(515): Attempt to read object from Parcel 0x59e1d554 at offset 68 that is not in the object list 02-24 16:04:08.666: I/AppCheck(3425): oldcom.lenovo.launcher------------new:com.GDSCP.ModileEnforces 02-24 16:04:08.666: I/AppCheck(3425): runningTask------------action:com.lenovo.safecenter.activityswitch com.GDSCP.ModileEnforces com.lenovo.launcher 02-24 16:04:08.670: I/AppCheck(3425): runningTask------------end///有启动这一块和成功一样 02-24 16:04:08.673: I/LeemCenterReceiver(3425): onReceive() 02-24 16:04:08.673: I/AppCheck(3425): recentTask------------action:com.lenovo.safecenter.activityswitch2 com.GDSCP.ModileEnforces com.lenovo.launcher 02-24 16:04:08.678: I/AppCheck(3425): recentTask------------end 02-24 16:04:08.680: I/LeemCenterReceiver(3425): newPkg interval == 1393229048676 02-24 16:04:08.680: I/LeemCenterReceiver(3425): cur == 1393229048680 bootTime == 0 time == 1393229048676 02-24 16:04:08.680: I/ydp(3425): pkg---->com.GDSCP.ModileEnforces 02-24 16:04:08.680: E/ydp(3425): checkApp pkgName:com.GDSCP.ModileEnforces 02-24 16:04:08.686: I/safepaymen(3425): clearNotify Pkg:com.lenovo.launcher 02-24 16:04:08.973: I/System.out(27227): [CDS]close[3880] 02-24 16:04:08.974: I/System.out(27227): close [socket][/0.0.0.0:-1] 02-24 16:04:09.153: I/SurfaceTextureClient(753): [STC::queueBuffer] (this:0x533b9830) fps:0.17, dur:5936.61, max:5936.61, min:5936.61 02-24 16:04:09.153: I/SurfaceTextureClient(753): [STC::queueBuffer] this:0x533b9830, api:1, last queue time elapsed:5936.61 02-24 16:04:09.154: I/BufferQueue(133): [StatusBar](this:0x41e1fc20,api:1) [queue] fps:0.17, dur:5930.55, max:5930.55, min:5930.55 02-24 16:04:09.156: I/BufferQueue(133): [StatusBar](this:0x41e1fc20,api:1) [release] fps:0.17, dur:5937.69, max:5937.69, min:5937.69 02-24 16:04:09.157: I/SurfaceFlinger(133): [SurfaceFlinger] fps:19.939392,dur:1504.56,max:601.98,min:1.02 02-24 16:04:15.295: I/SurfaceTextureClient(753): [STC::queueBuffer] (this:0x533b9830) fps:0.16, dur:6142.08, max:6142.08, min:6142.08 02-24 16:04:15.296: I/SurfaceTextureClient(753): [STC::queueBuffer] this:0x533b9830, api:1, last queue time elapsed:6142.08 02-24 16:04:15.297: I/BufferQueue(133): [StatusBar](this:0x41e1fc20,api:1) [queue] fps:0.16, dur:6142.83, max:6142.83, min:6142.83 02-24 16:04:15.311: I/BufferQueue(133): [StatusBar](this:0x41e1fc20,api:1) [release] fps:0.16, dur:6155.13, max:6155.13, min:6155.13 02-24 16:04:15.312: I/SurfaceFlinger(133): [SurfaceFlinger] fps:0.162469,dur:6155.03,max:6155.03,min:6155.03 02-24 16:04:17.978: W/ActivityManager(515): Launch timeout has expired, giving up wake lock! 02-24 16:04:18.074: W/ActivityManager(515): Activity idle timeout for ActivityRecord{41469980 u0 com.GDSCP.ModileEnforces/mobileenforces.BeginActivity} //启动失败 ......其后略
使用4.10.x的mono for andorid,解决了这个问题
仍然不清楚根源在哪儿。