04-14 12:04:30.971 1639-1938/system_process I/WindowManager: Destroying surface Surface(name=Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperChange) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.removeLocked:1449 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2478 com.android.server.wm.WindowManagerService.removeWindowLocked:2436 com.android.server.wm.WindowManagerService.removeWindowLocked:2305 com.android.server.wm.WindowManagerService.removeWindow:2300 com.android.server.wm.Session.remove:193
04-14 12:04:30.990 3852-3852/tianranwang.livewallpaper D/MainService: dispose
04-14 12:04:31.018 1639-1990/system_process I/WindowManager: Destroying surface Surface(name=tianranwang.livewallpaper.MainService) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.removeLocked:1449 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2478 com.android.server.wm.WindowManagerService.removeWindowLocked:2436 com.android.server.wm.WindowManagerService.removeWindowLocked:2305 com.android.server.wm.WindowManagerService.removeWindow:2300 com.android.server.wm.Session.remove:193
--------- beginning of crash
04-14 12:04:31.020 3852-4240/tianranwang.livewallpaper E/AndroidRuntime: FATAL EXCEPTION: Animation Thread
Process: tianranwang.livewallpaper, PID: 3852
java.lang.NullPointerException: Attempt to invoke interface method 'void android.view.SurfaceHolder.unlockCanvasAndPost(android.graphics.Canvas)' on a null object reference
at processing.a2d.PGraphicsAndroid2D.endDraw(Unknown Source)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PSurfaceNone.callDraw(Unknown Source)
at processing.core.PSurfaceNone$AnimationThread.run(Unknown Source)
Sur l'interface « fond d'écran de jeu », j'ai tourné l'écran et le dessin (dessin papier peint en direct) redémarré, et l'application écrasé (pas toujours écrasé), et l'esquisse (live wallpaper) a continué à courir sur le fond ..Android en direct wallpaer écrasé (NullPointerException, toile est un objet nul) mais je ne peux pas trouver où
Quelqu'un pourrait-il me donner un indice? Merci d'avance.
Le code source, que j'ai trouvé dans processing.a2d.PGraphicsAndroid2D.endDraw()
de https://github.com/processing/processing-android/tree/master/core/src/processing
public void endDraw() {
if (bitmap == null) return;
// hm, mark pixels as changed, because this will instantly do a full
// copy of all the pixels to the surface.. so that's kind of a mess.
//updatePixels();
// if (primaryGraphics) {
// if (canvas != null) {
// parent.getSurfaceHolder().unlockCanvasAndPost(canvas);
// }
// }
if (primaryGraphics) {
SurfaceHolder holder = parent.getSurface().getSurfaceHolder();
if (holder != null) {
Canvas screen = null;
try {
screen = holder.lockCanvas(null);
if (screen != null) {
screen.drawBitmap(bitmap, new Matrix(), null);
}
} finally {
if (screen != null) {
try {
holder.unlockCanvasAndPost(screen);
} catch (IllegalStateException ex) {
}
}
}
}
} else {
// TODO this is probably overkill for most tasks...
loadPixels();
}
// Marking as modified, and then calling updatePixels() in
// the super class, which just sets the mx1, my1, mx2, my2
// coordinates of the modified area. This avoids doing the
// full copy of the pixels to the surface in this.updatePixels().
setModified();
super.updatePixels();
}
Le code ci-dessus peut provoquer ce NullPointerException.
Je n'ai pas ce problème maintenant, parce que je mettre à jour la nouvelle version de traitement library..And le code ci-dessus est de la nouvelle version du lib. (Je ne peux pas voir le code de l'ancienne version)
Comment puis-je mettre en studio android point d'arrêt, lorsque ce NullPointerException dans cette discussion d'animation est jeté? – TrW236
Je n'ai pas ce problème maintenant, parce que je mets à jour la nouvelle version de la bibliothèque de traitement .. – TrW236