この問題は2.3のエミュレータでのみ発生するようです.
再現するソースコードです.
Java
package se.naru.android.usejavascriptinterface; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; import android.widget.Toast; public class UseJavaScriptInterfaceActivity extends Activity { @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final WebView webView = new WebView(this); webView.getSettings().setJavaScriptEnabled(true); webView.addJavascriptInterface(this, "android"); webView.loadUrl("file:///android_asset/index.html"); setContentView(webView); } public void click() { Toast.makeText(this, "Clicked", Toast.LENGTH_LONG).show(); } }
assets/index.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <button onclick="android.click()">Click!</button> </body> </html>
Android2.2のエミュレータでは問題なく動作します.
Android2.3のエミュレータで実行するとこのようなログとともにアプリが落ちます.
W/dalvikvm( 446): JNI WARNING: jarray 0x40544ad8 points to non-array object (Ljava/lang/String;) I/dalvikvm( 446): "WebViewCoreThread" prio=5 tid=9 NATIVE I/dalvikvm( 446): | group="main" sCount=0 dsCount=0 obj=0x4051b750 self=0x2986a0 I/dalvikvm( 446): | sysTid=455 nice=0 sched=0/0 cgrp=default handle=2732232 I/dalvikvm( 446): | schedstat=( 300585709 627657555 87 ) I/dalvikvm( 446): at android.webkit.WebViewCore.nativeTouchUp(Native Method) I/dalvikvm( 446): at android.webkit.WebViewCore.nativeTouchUp(Native Method) I/dalvikvm( 446): at android.webkit.WebViewCore.access$3300(WebViewCore.java:53) I/dalvikvm( 446): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1158) I/dalvikvm( 446): at android.os.Handler.dispatchMessage(Handler.java:99) I/dalvikvm( 446): at android.os.Looper.loop(Looper.java:123) I/dalvikvm( 446): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629) I/dalvikvm( 446): at java.lang.Thread.run(Thread.java:1019) I/dalvikvm( 446): E/dalvikvm( 446): VM aborting I/DEBUG ( 30): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** I/DEBUG ( 30): Build fingerprint: 'generic/sdk/generic:2.3.3/GRI34/101070:eng/test-keys' I/DEBUG ( 30): pid: 446, tid: 455 >>> se.naru.android.usejavascriptinterface <<< I/DEBUG ( 30): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadd00d I/DEBUG ( 30): r0 fffffec4 r1 deadd00d r2 00000026 r3 00000000 I/DEBUG ( 30): r4 800a45c0 r5 40544ad8 r6 80085acc r7 0029b9c0 I/DEBUG ( 30): r8 44012b54 r9 43eb0e4c 10 43eb0e34 fp 41edd8a0 I/DEBUG ( 30): ip 800a4720 sp 44012348 lr afd19375 pc 80045a4a cpsr 20000030 I/DEBUG ( 30): #00 pc 00045a4a /system/lib/libdvm.so I/DEBUG ( 30): #01 pc 00037748 /system/lib/libdvm.so I/DEBUG ( 30): #02 pc 00039a10 /system/lib/libdvm.so I/DEBUG ( 30): #03 pc 0003a4ec /system/lib/libdvm.so I/DEBUG ( 30): #04 pc 002989d6 /system/lib/libwebcore.so I/DEBUG ( 30): #05 pc 002120a4 /system/lib/libwebcore.so I/DEBUG ( 30): #06 pc 00113216 /system/lib/libwebcore.so I/DEBUG ( 30): #07 pc 00212b70 /system/lib/libwebcore.so I/DEBUG ( 30): #08 pc 002c716e /system/lib/libwebcore.so I/DEBUG ( 30): #09 pc 002ca4c6 /system/lib/libwebcore.so I/DEBUG ( 30): #10 pc 002d83b0 /system/lib/libwebcore.so I/DEBUG ( 30): #11 pc 002cfae8 /system/lib/libwebcore.so I/DEBUG ( 30): #12 pc 0020ce24 /system/lib/libwebcore.so I/DEBUG ( 30): #13 pc 001a0966 /system/lib/libwebcore.so I/DEBUG ( 30): #14 pc 001a6ef4 /system/lib/libwebcore.so I/DEBUG ( 30): #15 pc 001a4cd4 /system/lib/libwebcore.so I/DEBUG ( 30): #16 pc 001a4e1a /system/lib/libwebcore.so I/DEBUG ( 30): #17 pc 001a80a2 /system/lib/libwebcore.so I/DEBUG ( 30): #18 pc 001a8236 /system/lib/libwebcore.so I/DEBUG ( 30): #19 pc 00065108 /system/lib/libwebcore.so I/DEBUG ( 30): #20 pc 00065cae /system/lib/libwebcore.so I/DEBUG ( 30): #21 pc 001254e2 /system/lib/libwebcore.so I/DEBUG ( 30): #22 pc 001255da /system/lib/libwebcore.so I/DEBUG ( 30): #23 pc 00125600 /system/lib/libwebcore.so I/DEBUG ( 30): #24 pc 00017d74 /system/lib/libdvm.so I/DEBUG ( 30): I/DEBUG ( 30): code around pc: I/DEBUG ( 30): 80045a28 447a4479 ed0cf7d1 20004c09 ee34f7d1 I/DEBUG ( 30): 80045a38 447c4808 6bdb5823 d0002b00 49064798 I/DEBUG ( 30): 80045a48 700a2226 eea0f7d1 000436b7 00045275 I/DEBUG ( 30): 80045a58 0005eb82 fffffec4 deadd00d b510b40e I/DEBUG ( 30): 80045a68 4c0a4b09 447bb083 aa05591b 6b5bca02 I/DEBUG ( 30): I/DEBUG ( 30): code around lr: I/DEBUG ( 30): afd19354 b0834a0d 589c447b 26009001 686768a5 I/DEBUG ( 30): afd19364 220ce008 2b005eab 1c28d003 47889901 I/DEBUG ( 30): afd19374 35544306 d5f43f01 2c006824 b003d1ee I/DEBUG ( 30): afd19384 bdf01c30 000281a8 ffffff88 1c0fb5f0 I/DEBUG ( 30): afd19394 43551c3d a904b087 1c16ac01 604d9004 I/DEBUG ( 30): I/DEBUG ( 30): stack: I/DEBUG ( 30): 44012308 00000015 I/DEBUG ( 30): 4401230c afd18407 /system/lib/libc.so I/DEBUG ( 30): 44012310 afd4270c /system/lib/libc.so I/DEBUG ( 30): 44012314 afd426b8 /system/lib/libc.so I/DEBUG ( 30): 44012318 00000000 I/DEBUG ( 30): 4401231c afd19375 /system/lib/libc.so I/DEBUG ( 30): 44012320 002986a0 [heap] I/DEBUG ( 30): 44012324 afd183d9 /system/lib/libc.so I/DEBUG ( 30): 44012328 0029b9c0 [heap] I/DEBUG ( 30): 4401232c 0005eb82 [heap] I/DEBUG ( 30): 44012330 40544ad8 /dev/ashmem/dalvik-heap (deleted) I/DEBUG ( 30): 44012334 80085acc /system/lib/libdvm.so I/DEBUG ( 30): 44012338 0029b9c0 [heap] I/DEBUG ( 30): 4401233c afd18437 /system/lib/libc.so I/DEBUG ( 30): 44012340 df002777 I/DEBUG ( 30): 44012344 e3a070ad I/DEBUG ( 30): #00 44012348 00000001 I/DEBUG ( 30): 4401234c 8003774d /system/lib/libdvm.so I/DEBUG ( 30): #01 44012350 00000001 I/DEBUG ( 30): 44012354 80039a15 /system/lib/libdvm.so D/Zygote ( 32): Process 446 terminated by signal (11) I/ActivityManager( 74): Process se.naru.android.usejavascriptinterface (pid 446) has died. E/InputDispatcher( 74): channel '406cf340 se.naru.android.usejavascriptinterface/se.naru.android.usejavascriptinterface.UseJavaScriptInterfaceActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8 E/InputDispatcher( 74): channel '406cf340 se.naru.android.usejavascriptinterface/se.naru.android.usejavascriptinterface.UseJavaScriptInterfaceActivity (server)' ~ Channel is unrecoverably broken and will be disposed! I/WindowManager( 74): WIN DEATH: Window{406cf340 se.naru.android.usejavascriptinterface/se.naru.android.usejavascriptinterface.UseJavaScriptInterfaceActivity paused=false} W/InputManagerService( 74): Got RemoteException sending setActive(false) notification to pid 446 uid 10034
0 件のコメント:
コメントを投稿