我在cosos2dx上为ios设备制作了游戏。现在我想把它移植到Android但是,适用于ios的代码正在崩溃为android。 eclipse显示了3种类型的logCat输出,如下所示。
/////////////////////////////////////////////// ////////////////////////////////////////////////// //////
1) 11-27 10:41:05.168: W/SharedBufferStack(4417): waitForCondition(LockCondition) timed out (identity=302, status=0). CPU may be pegged. trying again.
/////////////////////////////////////////////// ////////////////////////////////////////////////// //////
2) 11-27 10:41:36.448: D/lights(248): set_light_backlight: brightness=255
11-27 10:41:41.518: I/InputDispatcher(248): Application is not responding: Window{2b452080 org.cocos2dx.Saburbia_android/org.cocos2dx.Saburbia_android.Saburbia_android paused=false}. 5000.4ms since event, 5000.4ms since wait started
11-27 10:41:41.518: I/WindowManager(248): Input event dispatching timed out sending to org.cocos2dx.Saburbia_android/org.cocos2dx.Saburbia_android.Saburbia_android
11-27 10:41:41.528: I/Process(248): Sending signal. PID: 4417 SIG: 3
11-27 10:41:41.528: I/dalvikvm(4417): threadid=4: reacting to signal 3
11-27 10:41:41.728: I/Process(248): Sending signal. PID: 248 SIG: 3
11-27 10:41:41.728: I/dalvikvm(248): threadid=4: reacting to signal 3
11-27 10:41:41.748: I/dalvikvm(248): Wrote stack traces to '/data/anr/traces.txt'
11-27 10:41:41.748: I/Process(248): Sending signal. PID: 355 SIG: 3
11-27 10:41:41.748: I/dalvikvm(355): threadid=4: reacting to signal 3
11-27 10:41:41.758: I/dalvikvm(355): Wrote stack traces to '/data/anr/traces.txt'
11-27 10:41:41.758: I/Process(248): Sending signal. PID: 320 SIG: 3
11-27 10:41:41.758: I/dalvikvm(320): threadid=4: reacting to signal 3
11-27 10:41:41.758: I/dalvikvm(320): Wrote stack traces to '/data/anr/traces.txt'
11-27 10:41:41.968: D/dalvikvm(248): GC_EXPLICIT freed 952K, 49% free 6943K/13447K, external 3286K/4888K, paused 78ms
11-27 10:41:42.518: E/ActivityManager(248): ANR in org.cocos2dx.Saburbia_android (org.cocos2dx.Saburbia_android/.Saburbia_android)
11-27 10:41:42.518: E/ActivityManager(248): Reason: keyDispatchingTimedOut
11-27 10:41:42.518: E/ActivityManager(248): Load: 7.93 / 7.92 / 7.79
11-27 10:41:42.518: E/ActivityManager(248): CPU usage from 27270ms to 0ms ago:
11-27 10:41:42.518: E/ActivityManager(248): 99% 4417/org.cocos2dx.Saburbia_android: 99% user + 0% kernel / faults: 2 minor
11-27 10:41:42.518: E/ActivityManager(248): 0% 3877/com.google.android.apps.maps: 0% user + 0% kernel / faults: 418 minor
11-27 10:41:42.518: E/ActivityManager(248): 0% 3957/com.svox.pico: 0% user + 0% kernel / faults: 678 minor
11-27 10:41:42.518: E/ActivityManager(248): 0% 248/system_server: 0% user + 0% kernel / faults: 8 minor
11-27 10:41:42.518: E/ActivityManager(248): 0% 1679/com.sonyericsson.customization: 0% user + 0% kernel / faults: 283 minor
11-27 10:41:42.518: E/ActivityManager(248): 0% 3647/com.sonyericsson.devicemonitor: 0% user + 0% kernel / faults: 179 minor
11-27 10:41:42.518: E/ActivityManager(248): 0% 121/rild: 0% user + 0% kernel / faults: 1 minor
11-27 10:41:42.518: E/ActivityManager(248): 0% 320/com.android.systemui: 0% user + 0% kernel / faults: 3 minor
11-27 10:41:42.518: E/ActivityManager(248): 0% 3731/com.sonyericsson.android.datamonitor: 0% user + 0% kernel / faults: 25 minor
11-27 10:41:42.518: E/ActivityManager(248): 100% TOTAL: 100% user + 0% kernel
11-27 10:41:42.518: E/ActivityManager(248): CPU usage from 461ms to 976ms later:
11-27 10:41:42.518: E/ActivityManager(248): 98% 4417/org.cocos2dx.Saburbia_android: 98% user + 0% kernel
11-27 10:41:42.518: E/ActivityManager(248): 96% 4418/HeapWorker: 96% user + 0% kernel
11-27 10:41:42.518: E/ActivityManager(248): 3.8% 248/system_server: 1.9% user + 1.9% kernel
11-27 10:41:42.518: E/ActivityManager(248): 1.9% 291/InputDispatcher: 0% user + 1.9% kernel
11-27 10:41:42.518: E/ActivityManager(248): 1.9% 442/er$SensorThread: 1.9% user + 0% kernel
11-27 10:41:42.518: E/ActivityManager(248): 100% TOTAL: 98% user + 1.9% kernel
11-27 10:41:42.518: I/InputDispatcher(248): Dropping event because the pointer is not down.
/////////////////////////////////////////////// ///////////////////////////////////////////////// < / p>
3)并且第三个原因是unknows,因为它在logCat中显示了meny内存地址。
/////////////////////////////////////////////// ///////////////////////////////////////////////// < / p>
我使用libcurl进行Web调用,使用pThread进行线程调用。这个游戏还有Facebook集成,使用Facebook API for mobile(Hackbook)完成。
在facebook登录后,本机代码使用libcurl连接到服务器,并使用pThread进行大约30次http调用,因此不应暂停渲染线程以获取服务器的响应。仍在进行此加载时,logcat会显示这3个日志中的任何一个并从头开始重新加载。游戏中还存在使用pThreads执行的http请求,但在游戏中也会显示这3个日志和崩溃中的任何一个。
相同的代码适用于ios构建。我无法找到为什么它无法正常运行Android。请建议是否必须遵循Android移植的任何规则。
我使用的版本如下。 Android NDK:r8b Cocos2dx:2.0.3 Eclipse:3.6.2 Android版本:2.2 系统:Ubuntu 10.0.4 设备:SonyEricsson NeoV(android2.3.4),三星Galaxy SII(android4.0.3)。
提前致谢..
答案 0 :(得分:0)
尝试在iPhone中查找内存问题,因为自动释放代码可能无法正常工作。 还可以使用NDK堆栈获取更多详细信息错误。 更新:另一种在远程跟踪ndk堆栈的方法使用https://www.crittercism.com 谢谢。