2013-01-13 34 views
1

我的代碼工作正常,當我運行它正常,但是當我運行這個單元測試這個錯誤打印在控制檯。我在這個單元測試中做錯了什麼?儀表運行失敗,由於'進程崩潰'

測試運行失敗:由於'進程崩潰'導致測試運行失敗。

logcat的

01-13 03:52:12.560: I/DEBUG(31): *** *** *** *** *** *** *** *** *** *** *** *** *** 

*** *** *** 
01-13 03:52:12.560: I/DEBUG(31): Build fingerprint: 'generic/sdk/generic/:2.2/FRF91/43546:eng/test-keys' 
01-13 03:52:12.560: I/DEBUG(31): pid: 446, tid: 452 >>> com.frozendragon.Sceptrum <<< 
01-13 03:52:12.560: I/DEBUG(31): signal 11 (SIGSEGV), fault addr 00000028 
01-13 03:52:12.560: I/DEBUG(31): r0 00000000 r1 0026148c r2 00000000 r3 0026148c 
01-13 03:52:12.560: I/DEBUG(31): r4 00260bd8 r5 002614cc r6 00000000 r7 00000000 
01-13 03:52:12.560: I/DEBUG(31): r8 00000001 r9 00000000 10 00000000 fp 00000000 
01-13 03:52:12.560: I/DEBUG(31): ip 00000000 sp 485c1b38 lr 00000000 pc ab166044 cpsr 60000010 
01-13 03:52:12.606: I/DEBUG(31):   #00 pc 00066044 /system/lib/libskia.so 
01-13 03:52:12.606: I/DEBUG(31):   #01 pc 00068bb4 /system/lib/libskia.so 
01-13 03:52:12.606: I/DEBUG(31):   #02 pc 00064e68 /system/lib/libskia.so 
01-13 03:52:12.606: I/DEBUG(31):   #03 pc 0004b1ea /system/lib/libandroid_runtime.so 
01-13 03:52:12.606: I/DEBUG(31):   #04 pc 00013974 /system/lib/libdvm.so 
01-13 03:52:12.606: I/DEBUG(31):   #05 pc 0003ddb4 /system/lib/libdvm.so 
01-13 03:52:12.606: I/DEBUG(31):   #06 pc 00037186 /system/lib/libdvm.so 
01-13 03:52:12.606: I/DEBUG(31):   #07 pc 00018714 /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #08 pc 0001e8c4 /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #09 pc 0001d790 /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #10 pc 0005408e /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #11 pc 0005bde2 /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #12 pc 00018714 /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #13 pc 0001e8c4 /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #14 pc 0001d790 /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #15 pc 00053eec /system/lib/libdvm.so 
01-13 03:52:12.616: I/DEBUG(31):   #16 pc 00054102 /system/lib/libdvm.so 
01-13 03:52:12.626: I/DEBUG(31):   #17 pc 0004825a /system/lib/libdvm.so 
01-13 03:52:12.626: I/DEBUG(31):   #18 pc 0001103c /system/lib/libc.so 
01-13 03:52:12.626: I/DEBUG(31):   #19 pc 00010b20 /system/lib/libc.so 
01-13 03:52:12.626: I/DEBUG(31): code around pc: 
01-13 03:52:12.626: I/DEBUG(31): ab166024 e59d001c e3a01000 e5c010a8 eaffff95 
01-13 03:52:12.626: I/DEBUG(31): ab166034 e1d4e2f4 e1d472f6 e5946004 e197200e 
01-13 03:52:12.626: I/DEBUG(31): ab166044 e5969028 e596a024 0a00002e e59db00c 
01-13 03:52:12.626: I/DEBUG(31): ab166054 e2848028 e1a0c008 e8bb000f e8ac000f 
01-13 03:52:12.626: I/DEBUG(31): ab166064 e8bb000f e8ac000f e89b0003 e26eb000 
01-13 03:52:12.626: I/DEBUG(31): code around lr: 
01-13 03:52:12.626: I/DEBUG(31): stack: 
01-13 03:52:12.626: I/DEBUG(31):  485c1af8 43480000 /data/dalvik-cache/[email protected]@[email protected] 
01-13 03:52:12.626: I/DEBUG(31):  485c1afc 002613c8 [heap] 
01-13 03:52:12.626: I/DEBUG(31):  485c1b00 485c1be8 
01-13 03:52:12.626: I/DEBUG(31):  485c1b04 00261020 [heap] 
01-13 03:52:12.626: I/DEBUG(31):  485c1b08 485c1be8 
01-13 03:52:12.626: I/DEBUG(31):  485c1b0c ab165be8 /system/lib/libskia.so 
01-13 03:52:12.626: I/DEBUG(31):  485c1b10 00000001 
01-13 03:52:12.636: I/DEBUG(31):  485c1b14 00000007 
01-13 03:52:12.636: I/DEBUG(31):  485c1b18 420d1a98 /dev/ashmem/dalvik-LinearAlloc (deleted) 
01-13 03:52:12.636: I/DEBUG(31):  485c1b1c 80846dad /system/lib/libdvm.so 
01-13 03:52:12.636: I/DEBUG(31):  485c1b20 00000024 
01-13 03:52:12.636: I/DEBUG(31):  485c1b24 00231b78 [heap] 
01-13 03:52:12.636: I/DEBUG(31):  485c1b28 46002d90 /dev/ashmem/mspace/dalvik-heap/2 (deleted) 
01-13 03:52:12.636: I/DEBUG(31):  485c1b2c 8083d9b9 /system/lib/libdvm.so 
01-13 03:52:12.636: I/DEBUG(31):  485c1b30 df002777 
01-13 03:52:12.636: I/DEBUG(31):  485c1b34 e3a070ad 
01-13 03:52:12.636: I/DEBUG(31): #00 485c1b38 46002d90 /dev/ashmem/mspace/dalvik-heap/2 (deleted) 
01-13 03:52:12.636: I/DEBUG(31):  485c1b3c 8082e5b3 /system/lib/libdvm.so 
01-13 03:52:12.636: I/DEBUG(31):  485c1b40 00000000 
01-13 03:52:12.636: I/DEBUG(31):  485c1b44 002614a4 [heap] 
01-13 03:52:12.636: I/DEBUG(31):  485c1b48 00004000 
01-13 03:52:12.636: I/DEBUG(31):  485c1b4c ffffffff 
01-13 03:52:12.636: I/DEBUG(31):  485c1b50 00000000 
01-13 03:52:12.636: I/DEBUG(31):  485c1b54 00261020 [heap] 
01-13 03:52:12.636: I/DEBUG(31):  485c1b58 485c1be8 
01-13 03:52:12.636: I/DEBUG(31):  485c1b5c 002316e8 [heap] 
01-13 03:52:12.636: I/DEBUG(31):  485c1b60 46002d90 /dev/ashmem/mspace/dalvik-heap/2 (deleted) 
01-13 03:52:12.636: I/DEBUG(31):  485c1b64 ad32e451 /system/lib/libandroid_runtime.so 
01-13 03:52:12.636: I/DEBUG(31):  485c1b68 ad374d50 /system/lib/libandroid_runtime.so 
01-13 03:52:12.636: I/DEBUG(31):  485c1b6c ad34bf0f /system/lib/libandroid_runtime.so 
01-13 03:52:12.636: I/DEBUG(31):  485c1b70 485c1f00 
01-13 03:52:12.636: I/DEBUG(31):  485c1b74 485c1be8 
01-13 03:52:12.646: I/DEBUG(31):  485c1b78 00261020 [heap] 
01-13 03:52:12.646: I/DEBUG(31):  485c1b7c ab165b68 /system/lib/libskia.so 
01-13 03:52:12.646: I/DEBUG(31):  485c1b80 485c1be8 
01-13 03:52:12.646: I/DEBUG(31):  485c1b84 485c1c0c 
01-13 03:52:12.646: I/DEBUG(31):  485c1b88 485c1bb0 
01-13 03:52:12.646: I/DEBUG(31):  485c1b8c 00261020 [heap] 
01-13 03:52:12.646: I/DEBUG(31):  485c1b90 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1b94 00000001 
01-13 03:52:12.646: I/DEBUG(31):  485c1b98 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1b9c 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1ba0 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1ba4 ab168bb8 /system/lib/libskia.so 
01-13 03:52:12.646: I/DEBUG(31): #01 485c1ba8 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1bac 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1bb0 000013fc 
01-13 03:52:12.646: I/DEBUG(31):  485c1bb4 000001b8 
01-13 03:52:12.646: I/DEBUG(31):  485c1bb8 485c1c68 
01-13 03:52:12.646: I/DEBUG(31):  485c1bbc 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1bc0 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1bc4 00000000 
01-13 03:52:12.646: I/DEBUG(31):  485c1bc8 00261020 [heap] 
01-13 03:52:12.646: I/DEBUG(31):  485c1bcc 433f6c68 /data/dalvik-cache/[email protected]@[email protected] 
01-13 03:52:12.646: I/DEBUG(31):  485c1bd0 8086caa4 /system/lib/libdvm.so 
01-13 03:52:12.646: I/DEBUG(31):  485c1bd4 80870eea /system/lib/libdvm.so 
01-13 03:52:12.646: I/DEBUG(31):  485c1bd8 000013fc 
01-13 03:52:12.646: I/DEBUG(31):  485c1bdc 80887fc4 /system/lib/libdvm.so 
01-13 03:52:12.646: I/DEBUG(31):  485c1be0 485c1f00 
01-13 03:52:12.656: I/DEBUG(31):  485c1be4 485c1c0c 
01-13 03:52:12.656: I/DEBUG(31):  485c1be8 00261020 [heap] 
01-13 03:52:12.656: I/DEBUG(31):  485c1bec 00000003 
01-13 03:52:12.656: I/DEBUG(31):  485c1bf0 00000000 
01-13 03:52:12.656: I/DEBUG(31):  485c1bf4 485c1c68 
01-13 03:52:12.656: I/DEBUG(31):  485c1bf8 43957d20 
01-13 03:52:12.656: I/DEBUG(31):  485c1bfc 43957d0c 
01-13 03:52:12.656: I/DEBUG(31):  485c1c00 00231b78 [heap] 
01-13 03:52:12.656: I/DEBUG(31):  485c1c04 ab164e6c /system/lib/libskia.so 
01-13 03:52:13.006: I/BootReceiver(73): Copying /data/tombstones/tombstone_07 to DropBox (SYSTEM_TOMBSTONE) 
01-13 03:52:13.026: D/Zygote(33): Process 446 terminated by signal (11) 
01-13 03:52:13.076: D/dalvikvm(73): GC_FOR_MALLOC freed 4012 objects/829984 bytes in 66ms 
01-13 03:52:13.076: I/ActivityManager(73): Process com.frozendragon.Sceptrum (pid 446) has died. 
01-13 03:52:13.076: W/ActivityManager(73): Crash of app com.frozendragon.Sceptrum running instrumentation ComponentInfo{com.frozendragon.Sceptrum.test/android.test.InstrumentationTestRunner} 
01-13 03:52:13.076: I/ActivityManager(73): Force stopping package com.frozendragon.Sceptrum uid=10028 
01-13 03:52:13.087: D/AndroidRuntime(440): Shutting down VM 
01-13 03:52:13.087: D/jdwp(440): Got wake-up signal, bailing out of select 
01-13 03:52:13.087: D/dalvikvm(440): Debugger has detached; object registry had 1 entries 
01-13 03:54:28.720: D/SntpClient(73): request time failed: java.net.SocketException: Address family not supported by protocol 

單元測試代碼

Point ImagesPos, SheetSize, CurrentSprite, Size; 
    protected void setUp() throws Exception { 
     super.setUp(); 
     gameEngine = new GameEngine(400, 800); 
     canvas = new Canvas(); 
     ImagesPos = new Point(200, 200); 
     SheetSize = new Point(9, 9); 
     CurrentSprite = new Point(2, 3); 
     Size = new Point(200, 400); 
     Context context = getContext(); 
     BitmapFactory.Options options = new BitmapFactory.Options(); 
     options.inScaled = true; 
     animationbmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.foot_animation_spritesheet9x9, options); 
    } 
    public void testDrawAnimationObjectCanvasBitmapIntIntPointPointFloat() { 
     float rot = 45f; 
     gameEngine.DrawAnimationObject(canvas, animationbmp, ImagesPos.x, ImagesPos.y, SheetSize, CurrentSprite, rot); 
     animationbmp.recycle(); 
     gameEngine.DrawAnimationObject(canvas, animationbmp, ImagesPos.x, ImagesPos.y, SheetSize, CurrentSprite, rot); 
     restorebmp(); 
    } 
private void restorebmp() 
{ 
    if(animationbmp.isRecycled() == false) 
    { 
     animationbmp.recycle(); 
    } 
    Context context = getContext(); 
    BitmapFactory.Options options = new BitmapFactory.Options(); 
    options.inScaled = true; 
    animationbmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.foot_animation_spritesheet9x9, options); 
} 
+0

系統庫以不應該出現的方式崩潰應用程序。你無法做任何事情,在http://code.google.com/p/android/issues/list上提出問題 - 是模擬器嗎?在這種情況下使用更新的圖像。 – auselen

回答

2

看來你的代碼是再造一個位圖,然後立即試圖再次使用它:

gameEngine.DrawAnimationObject(canvas, animationbmp, ImagesPos.x, ImagesPos.y, SheetSize, CurrentSprite, rot); 
    ////////////////////////////////////////////// 
    animationbmp.recycle(); //Offending line here/ 
    ////////////////////////////////////////////// 
    gameEngine.DrawAnimationObject(canvas, animationbmp, ImagesPos.x, ImagesPos.y, SheetSize, CurrentSprite, rot); 

你不應該使用位圖它被回收後。您需要重新創建該位圖對象,因爲內存現在無效。

+0

這可能不是obiouse,但我試圖測試該方法可以處理已回收的圖像,而不是繪製它。當我在調試中逐行通過代碼行時,它工作正常。你有什麼想法如何測試這個? – Frozendragon

+0

嗯,我不確定DrawAnimationObject在做什麼,你應該仍然可以訪問Bitmap類的僅Java部分。例如,在嘗試從位圖訪問原始圖像數據之前,仍然可以在DrawAnimationObject中檢查isRecycled()(並且在我看來,您希望它被檢查)。換句話說,如果你看看Bitmap的源代碼,請確保你不要調用任何本地調用的方法。我懷疑它只是在偶然的情況下以調試模式工作。本地位圖代碼正在訪問JVM中不再分配給位圖的內存。 –

1

A C++庫你打電話,試圖取消引用的內存地址爲0x00 ...... 28墜毀。看起來像libskia.so,這是android處理圖形子系統的一部分。該內存地址意味着它可能正在查看數組中的第N個項目,但數組爲空。我會尋找一個空指針被傳遞給繪圖調用,或者做一些嚴重的谷歌搜索libskia錯誤。恐怕我的幫助不止於此,而是一個開始。

相關問題