我的 logcat 中出现什么错误?
我现在快完成我的游戏了,但是今天我遇到了一个真正烦人的问题。当我启动游戏,只等几秒钟,程序就自动关闭。我对此没有任何解释。
这就是我的 logcat 显示的内容:
01-22 16:20:31.232: DEBUG/szipinf(333): Initializing inflate state
01-22 16:20:31.563: DEBUG/PhoneWindow(333): couldn't save which view has focus because the focused view com.JDLApps.Snake.FrameWork.AndroidFastRenderView@4050f950 has no id.
01-22 16:20:36.362: WARN/ActivityManager(73): Activity pause timeout for HistoryRecord{406532f8 com.JDL.Apps.Snake/.SnakeGame}
01-22 16:20:43.682: INFO/ActivityManager(73): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=358 uid=10026 gids={}
01-22 16:21:20.393: ERROR/InputDispatcher(73): channel '406762c0 com.JDL.Apps.Snake/com.JDL.Apps.Snake.SnakeGame (server)' ~ Consumer closed input channel or an error occurred. events=0x8
01-22 16:21:20.402: ERROR/InputDispatcher(73): channel '406762c0 com.JDL.Apps.Snake/com.JDL.Apps.Snake.SnakeGame (server)' ~ Channel is unrecoverably broken and will be disposed!
01-22 16:21:21.092: INFO/WindowManager(73): WIN DEATH: Window{406762c0 com.JDL.Apps.Snake/com.JDL.Apps.Snake.SnakeGame paused=false}
01-22 16:21:21.142: WARN/ActivityManager(73): Timeout of broadcast BroadcastRecord{40728640 android.intent.action.TIME_TICK} - receiver=android.app.LoadedApk$ReceiverDispatcher$InnerReceiver@406300f8, started 56630ms ago
01-22 16:21:21.142: WARN/ActivityManager(73): Receiver during timeout: BroadcastFilter{4062f930 ReceiverList{4062f8b8 73 system/1000 local:406300f8}}
01-22 16:21:21.172: INFO/ActivityManager(73): Process com.JDL.Apps.Snake (pid 333) has died.
01-22 16:21:21.362: INFO/WindowManager(73): WIN DEATH: Window{4072b188 SurfaceView paused=false}
01-22 16:21:21.443: INFO/ActivityManager(73): Low Memory: No more background processes.
不幸的是,我没有代码可以分享,因为我不知道程序是否崩溃。
编辑:绘图代码:
@Override
public void screen(float deltaTime) {
Graphics g = app.getGraphics();
g.drawPixmap(Assets.background, 0, 0);
g.drawPixmap(Assets.facebook, 750, 20);
g.drawText("SNAKE", 10, 150, Color.BLACK, 150, AndroidGraphics.LEFT,
null, 0);
g.drawText("START", g.getWidth() / 2, g.getHeight() - 20, Color.BLACK,
120, AndroidGraphics.CENTER, startRec, 0);
g.drawText("HIGHSCORE", 20, 275, Color.BLACK, 50, AndroidGraphics.LEFT,
highRec, 0);
g.drawText("MORE APPS", g.getWidth() - 20, 275, Color.BLACK, 50,
AndroidGraphics.RIGHT, moreRec, 0);
if (Settings.soundEnabled)
g.drawPixmap(Assets.buttons, new Rect(0, 0, 100, 100), new Rect(0,
380, 100, 480));
else
g.drawPixmap(Assets.buttons, new Rect(100, 0, 200, 100), new Rect(
0, 380, 100, 480));
}
drawText方法:
@Override
public void drawText(String text, int x, int y, int color, int size,
int position, Rect bounds, int rotation) {
if (position == LEFT)
paint.setTextAlign(Paint.Align.LEFT);
else if (position == CENTER)
paint.setTextAlign(Paint.Align.CENTER);
else if (position == RIGHT)
paint.setTextAlign(Paint.Align.RIGHT);
else
return;
paint.setColor(color);
Typeface typeface = Typeface.createFromAsset(assets, "typewrite.TTF");
paint.setTypeface(typeface);
paint.setTextSize(size);
if (bounds != null) {
Rect rec = new Rect();
paint.getTextBounds(text, 0, text.length(), rec);
bounds.bottom = y;
bounds.top = y - rec.height();
if (position == CENTER) {
bounds.left = x - rec.width() / 2;
bounds.right = x + rec.width() / 2;
} else if (position == RIGHT) {
bounds.left = x - rec.width();
bounds.right = x;
} else if (position == LEFT) {
bounds.left = x;
bounds.right = x + rec.width();
} else
return;
}
canvas.save();
canvas.rotate(rotation, x, y);
canvas.drawText(text, x, y, paint);
canvas.restore();
}
I am almost finished with my game now, but today I encountered a real anoying problem. When I start the game and just wait for a few secounds, the program automaticly shuts down. And I ahve no explonation fot it.
This is what my logcat shows:
01-22 16:20:31.232: DEBUG/szipinf(333): Initializing inflate state
01-22 16:20:31.563: DEBUG/PhoneWindow(333): couldn't save which view has focus because the focused view com.JDLApps.Snake.FrameWork.AndroidFastRenderView@4050f950 has no id.
01-22 16:20:36.362: WARN/ActivityManager(73): Activity pause timeout for HistoryRecord{406532f8 com.JDL.Apps.Snake/.SnakeGame}
01-22 16:20:43.682: INFO/ActivityManager(73): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=358 uid=10026 gids={}
01-22 16:21:20.393: ERROR/InputDispatcher(73): channel '406762c0 com.JDL.Apps.Snake/com.JDL.Apps.Snake.SnakeGame (server)' ~ Consumer closed input channel or an error occurred. events=0x8
01-22 16:21:20.402: ERROR/InputDispatcher(73): channel '406762c0 com.JDL.Apps.Snake/com.JDL.Apps.Snake.SnakeGame (server)' ~ Channel is unrecoverably broken and will be disposed!
01-22 16:21:21.092: INFO/WindowManager(73): WIN DEATH: Window{406762c0 com.JDL.Apps.Snake/com.JDL.Apps.Snake.SnakeGame paused=false}
01-22 16:21:21.142: WARN/ActivityManager(73): Timeout of broadcast BroadcastRecord{40728640 android.intent.action.TIME_TICK} - receiver=android.app.LoadedApk$ReceiverDispatcher$InnerReceiver@406300f8, started 56630ms ago
01-22 16:21:21.142: WARN/ActivityManager(73): Receiver during timeout: BroadcastFilter{4062f930 ReceiverList{4062f8b8 73 system/1000 local:406300f8}}
01-22 16:21:21.172: INFO/ActivityManager(73): Process com.JDL.Apps.Snake (pid 333) has died.
01-22 16:21:21.362: INFO/WindowManager(73): WIN DEATH: Window{4072b188 SurfaceView paused=false}
01-22 16:21:21.443: INFO/ActivityManager(73): Low Memory: No more background processes.
I have unfortunately no code to share because I don't know were the program crashes.
EDIT: Drawing code:
@Override
public void screen(float deltaTime) {
Graphics g = app.getGraphics();
g.drawPixmap(Assets.background, 0, 0);
g.drawPixmap(Assets.facebook, 750, 20);
g.drawText("SNAKE", 10, 150, Color.BLACK, 150, AndroidGraphics.LEFT,
null, 0);
g.drawText("START", g.getWidth() / 2, g.getHeight() - 20, Color.BLACK,
120, AndroidGraphics.CENTER, startRec, 0);
g.drawText("HIGHSCORE", 20, 275, Color.BLACK, 50, AndroidGraphics.LEFT,
highRec, 0);
g.drawText("MORE APPS", g.getWidth() - 20, 275, Color.BLACK, 50,
AndroidGraphics.RIGHT, moreRec, 0);
if (Settings.soundEnabled)
g.drawPixmap(Assets.buttons, new Rect(0, 0, 100, 100), new Rect(0,
380, 100, 480));
else
g.drawPixmap(Assets.buttons, new Rect(100, 0, 200, 100), new Rect(
0, 380, 100, 480));
}
drawText method:
@Override
public void drawText(String text, int x, int y, int color, int size,
int position, Rect bounds, int rotation) {
if (position == LEFT)
paint.setTextAlign(Paint.Align.LEFT);
else if (position == CENTER)
paint.setTextAlign(Paint.Align.CENTER);
else if (position == RIGHT)
paint.setTextAlign(Paint.Align.RIGHT);
else
return;
paint.setColor(color);
Typeface typeface = Typeface.createFromAsset(assets, "typewrite.TTF");
paint.setTypeface(typeface);
paint.setTextSize(size);
if (bounds != null) {
Rect rec = new Rect();
paint.getTextBounds(text, 0, text.length(), rec);
bounds.bottom = y;
bounds.top = y - rec.height();
if (position == CENTER) {
bounds.left = x - rec.width() / 2;
bounds.right = x + rec.width() / 2;
} else if (position == RIGHT) {
bounds.left = x - rec.width();
bounds.right = x;
} else if (position == LEFT) {
bounds.left = x;
bounds.right = x + rec.width();
} else
return;
}
canvas.save();
canvas.rotate(rotation, x, y);
canvas.drawText(text, x, y, paint);
canvas.restore();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的某个地方有内存泄漏。请参阅开发人员文档中的此博文,了解可以使用的工具追踪它。另请参阅这篇博文,了解避免 Android 应用程序内存泄漏的编程技巧。
You have a memory leak somewhere. See this blog post in the developer docs for tools that you can use to track it down. Also see this blog post for programming tips to avoid leaking memory in Android applications.
看起来你的游戏使用了两次内存(或)内存泄漏。您可能需要使用 这个讨论并从那里获取。
It seems your game using two much memory (or) memory leak. You may need to log the memory usage of your process using some of techniques described in this discussion and take from there.
通过单步调试,我得到了详细错误:您必须在...中提供layout_height属性。它确实适合我的情况。
With the single-step debug, I got the detail error: you must supply layout_height attribute in .... It did work for my situation.