1. eclipse的Device中不显示手机
在eclipse中连接不上手机,出现adb server didn't ACK fail to start daemon 错误.
出现这种原因是因为adb所使用的5037端口被占用了.
使用adb kill-server 关闭adb服务 , 使用adb start-server开启adb命令 ; 如果5037端口被占用则会出现启动失败, 报出上述错误;
查看哪些进程占用了端口 : netstat -ano | findstr "5037" 会出现下面的结果
G:\Documents and Settings\Administrator>netstat -ano | findstr "5037"
TCP 127.0.0.1:1939 127.0.0.1:5037 ESTABLISHED 5748
TCP 127.0.0.1:1978 127.0.0.1:5037 ESTABLISHED 3000
TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 5748
TCP 127.0.0.1:5037 127.0.0.1:1939 ESTABLISHED 5748
TCP 127.0.0.1:5037 127.0.0.1:1977 CLOSE_WAIT 5748
TCP 127.0.0.1:5037 127.0.0.1:1978 ESTABLISHED 5748
可以看到 5748 3000 两个进程占用了5037端口.
打开进程管理器, 点击查看,选择列,将PID进程标示符勾选上,然后根据pid终止相应的进程.
这两个进程分别是豌豆荚 和 QQ , 同时将adb.exe 和 tadb.exe 进程干掉.
此时执行 adb start-server 命令即可启动adb服务 , 之后启动就会启动成功.
2. java.lang.OutOfMemoryError: thread creation failed 错误
10-17 09:51:58.830: E/AndroidRuntime(15695): FATAL EXCEPTION: Thread-316 10-17 09:51:58.830: E/AndroidRuntime(15695): java.lang.OutOfMemoryError: thread creation failed 10-17 09:51:58.830: E/AndroidRuntime(15695): at java.lang.VMThread.create(Native Method) 10-17 09:51:58.830: E/AndroidRuntime(15695): at java.lang.Thread.start(Thread.java:1050) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.alarm.AlarmPlayer.enqueue(AlarmPlayer.java:201) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.alarm.AlarmPlayer.resume(AlarmPlayer.java:192) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.director.MpmDirector.filterMpmHealthData(MpmDirector.java:270) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.director.MpmDirector.onHealthDataDecoded(MpmDirector.java:72) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.decoder.BaseDecoder.notifyAllDataDecodedListener(BaseDecoder.java:89) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.decoder.MpmEcgDecoder.caculateEcgResult(MpmEcgDecoder.java:394) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.decoder.MpmEcgDecoder.casulateResult(MpmEcgDecoder.java:269) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.decoder.MpmEcgDecoder.processBigPackageOfEcgData(MpmEcgDecoder.java:100) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.decoder.MpmEcgDecoder.processData(MpmEcgDecoder.java:87) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.decoder.MpmDecoder.operator(MpmDecoder.java:135) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.BqfjApplication$2.receiveData(BqfjApplication.java:148) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.bluetooth.BqfjBluetoothManager.notifyReceivers(BqfjBluetoothManager.java:281) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.bluetooth.BqfjConnectionManager$DataPump.run(BqfjConnectionManager.java:397) 10-17 09:51:58.830: E/AndroidRuntime(15695): at com.ivt.mHealth.util.ReusableThread.run(ReusableThread.java:85) 10-17 09:51:58.830: E/AndroidRuntime(15695): at java.lang.Thread.run(Thread.java:856) 10-17 09:51:58.920: V/StagefrightPlayer(1875): isPlaying 10-17 09:51:58.920: V/MediaPlayerService(1875): [20] isPlaying: 0 10-17 09:51:58.920: V/MediaPlayer(15695): isPlaying: 0 10-17 09:51:58.920: V/MediaPlayer-JNI(15695): isPlaying: 0 10-17 09:51:58.925: D/dalvikvm(2219): GC_FOR_ALLOC freed 1595K, 30% free 26891K/37895K, paused 77ms, total 77ms 10-17 09:51:58.930: E/SQLiteLog(15695): (14) cannot open file at line 30241 of [00bb9c9ce4] 10-17 09:51:58.930: E/SQLiteLog(15695): (14) os_unix.c:30241: (2) open(/NotificationPermissions.db) - 10-17 09:51:58.930: D/STATUSBAR-NetworkController(2441): refreshSignalCluster: data=-1 bt=false
开发中遇到了上述错误 , 后来发现是 使用了TraceView导致的
不知道在代码的什么地方添加了TraceView的相关代码 , 去掉之后 , 就好了
我在Activity中的onCreate()方法中添加了 :
Debug.startMethodTracing();
在onDestroy()方法中添加了 :
Debug.stopMethodTracing();
去掉了上述两行代码 , 就不会出现上述错误了 ;
3. Call requires API level 8 (current min is 1)错误
导入了一个程序 , 每次运行之后都会出现该错误 .
点击clean 错误就会消失 , 但是执行该错误的时候该错误就会重新出现 .
这个错误需要在AndroidManifest.xml配置文件中修改 user-sdk 标签
给user-sdk 添加一个android:minSdkVersion="8" 属性
4. 奇怪的空指针异常
今天出现一个奇怪的错误, 很简单空指针异常, 我只负责编码, 不管编译, 然后上传到SVN上, 结果出了下面的错误 , 看了半天 , 木有看懂 :
11-13 10:39:53.337: E/AndroidRuntime(11030): FATAL EXCEPTION: Thread-394 11-13 10:39:53.337: E/AndroidRuntime(11030): java.lang.NullPointerException 11-13 10:39:53.337: E/AndroidRuntime(11030): at com.ivt.mHealth.widget.aa.b(Unknown Source) 11-13 10:39:53.337: E/AndroidRuntime(11030): at com.ivt.mHealth.widget.DisplaySurfaceView.a(Unknown Source) 11-13 10:39:53.337: E/AndroidRuntime(11030): at com.ivt.mHealth.widget.ae.run(Unknown Source)
我一看 蒙了 , 这是什么错误 , 没定义过这个类啊 , 后来才想起来 这是代码混淆以后的效果 .
有点无语 ... 想了半小时才反应过来
我直接从SVN上down了一下代码, 重新编译下 , ╮(╯▽╰)╭ 拨云见日
11-13 10:41:57.432: E/AndroidRuntime(11507): FATAL EXCEPTION: Thread-398 11-13 10:41:57.432: E/AndroidRuntime(11507): java.lang.NullPointerException 11-13 10:41:57.432: E/AndroidRuntime(11507): at com.ivt.mHealth.widget.BpmSurface.drawMpmBpm(BpmSurface.java:169) 11-13 10:41:57.432: E/AndroidRuntime(11507): at com.ivt.mHealth.widget.BpmSurface.drawToSurfaceView(BpmSurface.java:109) 11-13 10:41:57.432: E/AndroidRuntime(11507): at com.ivt.mHealth.widget.DisplaySurfaceView.drawToSurface(DisplaySurfaceView.java:183) 11-13 10:41:57.432: E/AndroidRuntime(11507): at com.ivt.mHealth.widget.DisplaySurfaceView.access$1(DisplaySurfaceView.java:178) 11-13 10:41:57.432: E/AndroidRuntime(11507): at com.ivt.mHealth.widget.DisplaySurfaceView$RenderThread.run(DisplaySurfaceView.java:144)
以后千万不要看编译出来的产品的log , 都是混效过的 ........
这是少上传了一行代码到SVN上啊 ...... 泪奔 .... 半小时就这么浪费了
5. 内存溢出错误
adb shell dumpsys meminfo com.ivt.mHealth
08-12 12:48:52.798: I/dalvikvm-heap(15260): Clamp target GC heap from 64.996MB to 64.000MB 08-12 12:48:52.798: D/dalvikvm(15260): GC_FOR_ALLOC freed 1K, 3% free 63863K/65543K, paused 190ms, total 190ms 08-12 12:48:52.798: I/dalvikvm-heap(15260): Forcing collection of SoftReferences for 21473-byte allocation 08-12 12:48:52.988: I/dalvikvm-heap(15260): Clamp target GC heap from 64.987MB to 64.000MB 08-12 12:48:52.988: D/dalvikvm(15260): GC_BEFORE_OOM freed 9K, 3% free 63853K/65543K, paused 186ms, total 186ms 08-12 12:48:52.988: E/dalvikvm-heap(15260): Out of memory on a 21473-byte allocation. 08-12 12:48:52.988: I/dalvikvm(15260): "main" prio=5 tid=1 RUNNABLE 08-12 12:48:52.988: I/dalvikvm(15260): | group="main" sCount=0 dsCount=0 obj=0x40efd508 self=0x40d62778 08-12 12:48:52.988: I/dalvikvm(15260): | sysTid=15260 nice=0 sched=0/0 cgrp=apps handle=1074577200 08-12 12:48:52.988: I/dalvikvm(15260): | schedstat=( 21710980394 3466435126 36123 ) utm=1846 stm=324 core=1 08-12 12:48:52.988: I/dalvikvm(15260): at com.ivt.mHealth.util.ByteArrayBuffer.expand(ByteArrayBuffer.java:~28) 08-12 12:48:52.988: I/dalvikvm(15260): at com.ivt.mHealth.util.ByteArrayBuffer.append(ByteArrayBuffer.java:62) 08-12 12:48:52.988: I/dalvikvm(15260): at com.ivt.mHealth.util.BqfjHttpHeaderPacker.packHttpHeader(BqfjHttpHeaderPacker.java:185) 08-12 12:48:52.988: I/dalvikvm(15260): at com.ivt.mHealth.datacommunication.impl.BqfjSendRTMpmDataMessageHandler$PacketTransController.sendPacket(BqfjSendRTMpmDataMessageHandler.java:770) 08-12 12:48:52.988: I/dalvikvm(15260): at com.ivt.mHealth.datacommunication.impl.BqfjSendRTMpmDataMessageHandler$PacketTransController.onPacketReceived(BqfjSendRTMpmDataMessageHandler.java:814) 08-12 12:48:52.988: I/dalvikvm(15260): at com.ivt.mHealth.datacommunication.impl.BqfjSendRTMpmDataMessageHandler$1.handleMessage(BqfjSendRTMpmDataMessageHandler.java:526) 08-12 12:48:52.988: I/dalvikvm(15260): at android.os.Handler.dispatchMessage(Handler.java:99) 08-12 12:48:52.988: I/dalvikvm(15260): at android.os.Looper.loop(Looper.java:137) 08-12 12:48:52.988: I/dalvikvm(15260): at android.app.ActivityThread.main(ActivityThread.java:4921) 08-12 12:48:52.988: I/dalvikvm(15260): at java.lang.reflect.Method.invokeNative(Native Method) 08-12 12:48:52.988: I/dalvikvm(15260): at java.lang.reflect.Method.invoke(Method.java:511) 08-12 12:48:52.988: I/dalvikvm(15260): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 08-12 12:48:52.988: I/dalvikvm(15260): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 08-12 12:48:52.988: I/dalvikvm(15260): at dalvik.system.NativeStart.main(Native Method) 08-12 12:48:52.988: D/AndroidRuntime(15260): Shutting down VM 08-12 12:48:52.988: W/dalvikvm(15260): threadid=1: thread exiting with uncaught exception (group=0x40efc2a0) 08-12 12:48:52.993: V/BluetoothSocket.cpp(15260): readNative 08-12 12:48:52.993: E/AndroidRuntime(15260): FATAL EXCEPTION: main 08-12 12:48:52.993: E/AndroidRuntime(15260): java.lang.OutOfMemoryError 08-12 12:48:52.993: E/AndroidRuntime(15260): at com.ivt.mHealth.util.ByteArrayBuffer.expand(ByteArrayBuffer.java:28) 08-12 12:48:52.993: E/AndroidRuntime(15260): at com.ivt.mHealth.util.ByteArrayBuffer.append(ByteArrayBuffer.java:62) 08-12 12:48:52.993: E/AndroidRuntime(15260): at com.ivt.mHealth.util.BqfjHttpHeaderPacker.packHttpHeader(BqfjHttpHeaderPacker.java:185) 08-12 12:48:52.993: E/AndroidRuntime(15260): at com.ivt.mHealth.datacommunication.impl.BqfjSendRTMpmDataMessageHandler$PacketTransController.sendPacket(BqfjSendRTMpmDataMessageHandler.java:770) 08-12 12:48:52.993: E/AndroidRuntime(15260): at com.ivt.mHealth.datacommunication.impl.BqfjSendRTMpmDataMessageHandler$PacketTransController.onPacketReceived(BqfjSendRTMpmDataMessageHandler.java:814) 08-12 12:48:52.993: E/AndroidRuntime(15260): at com.ivt.mHealth.datacommunication.impl.BqfjSendRTMpmDataMessageHandler$1.handleMessage(BqfjSendRTMpmDataMessageHandler.java:526) 08-12 12:48:52.993: E/AndroidRuntime(15260): at android.os.Handler.dispatchMessage(Handler.java:99) 08-12 12:48:52.993: E/AndroidRuntime(15260): at android.os.Looper.loop(Looper.java:137) 08-12 12:48:52.993: E/AndroidRuntime(15260): at android.app.ActivityThread.main(ActivityThread.java:4921) 08-12 12:48:52.993: E/AndroidRuntime(15260): at java.lang.reflect.Method.invokeNative(Native Method) 08-12 12:48:52.993: E/AndroidRuntime(15260): at java.lang.reflect.Method.invoke(Method.java:511) 08-12 12:48:52.993: E/AndroidRuntime(15260): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 08-12 12:48:52.993: E/AndroidRuntime(15260): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 08-12 12:48:52.993: E/AndroidRuntime(15260): at dalvik.system.NativeStart.main(Native Method) 08-12 12:48:53.013: E/android.os.Debug(2224): !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error 08-12 12:48:53.018: I/dumpstate(308): begin