Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C649610BD7 for ; Wed, 11 Sep 2013 23:52:59 +0000 (UTC) Received: (qmail 699 invoked by uid 500); 11 Sep 2013 23:52:59 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 674 invoked by uid 500); 11 Sep 2013 23:52:59 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 666 invoked by uid 99); 11 Sep 2013 23:52:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Sep 2013 23:52:59 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [68.178.252.105] (HELO p3plsmtpa11-04.prod.phx3.secureserver.net) (68.178.252.105) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Sep 2013 23:52:51 +0000 Received: from chiron ([50.47.43.35]) by p3plsmtpa11-04.prod.phx3.secureserver.net with id Pzs81m00H0lXdyA01zs8cW; Wed, 11 Sep 2013 16:52:09 -0700 Message-ID: <63A892C02F1840E18101EEEC9161E92C@ECPCorp.local> From: "dev at watch2web.com" To: Subject: addJavascriptInterface fails on Android API levels 17 and 18 (4.2.2 and 4.3) Date: Wed, 11 Sep 2013 16:52:08 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0226_01CEAF0F.4083C1F0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.3790.4657 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4913 X-Virus-Checked: Checked by ClamAV on apache.org ------=_NextPart_000_0226_01CEAF0F.4083C1F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I recently changed the value of targetSdkVersion in my = AndroidManifest.xml from 16 to 18. They say, "Better late than never," = but maybe not in this case. I discovered that the change causes my app = to white-screen on startup on two Samsung Galaxy S4s -- both running API = level 17 (4.2.2). (On the five other devices I have -- all running API = 16 or lower -- everything still works as if nothing has changed.) If I = set targetSdkVersion back to 16, the app works great on all devices, = including both Samsungs. I am using Cordova 3.0.0. I have traced the problem to my onDeviceReady function, at the line = where it first tries to execute one of my @JavascriptInterface = functions. (It doesn't seem to matter which one.) Code snippet looks = like: (in main Activity) appView.addJavascriptInterface(this, "MyJSI"); @JavascriptInterface public void foo() { .... } (in onDeviceReady) if (window.MyJSI =3D=3D undefined) console.log("javascript interface is = undefined"); else if (window.MyJSI =3D=3D null) console.log("javascript interface is = null"); else if (typeof(window.MyJSI) =3D=3D 'object') console.log("javascript = interface is an object: " + window.MyJSI); else console.log("javascript interface is not an object"); window.MyJSI.foo(); // foo is just some method I wrote -- I've only = experimented with a few On both "good" (API level <=3D 16) and "bad" (Galaxy S4, API level >=3D = 17) phones I get in the console output: >> javascript interface is an object: [object Object] On the "good" phones, everything continues, and I get all the logging = that comes from subsequent parts of the app. On the "bad" phone, I get: >> Uncaught TypeError: Object [object Object] has no method 'foo' and things pretty much stop. You'd think I was in OK shape. I have a fix that involves changing one = character -- not even in code, just a settings file -- and it works on = all API levels. But NO, Google Play forbids lowering the = targetSdkVersion. So I need to fix this for real.=20 In searching, I found this issue from December. It isn't exactly what = I'm seeing since deviceready does fire for me. But a lot of the elements = seem very similar.=20 https://issues.apache.org/jira/browse/CB-1879?page=3Dcom.atlassian.jira.p= lugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D13501660#= comment-13501660 I'm happy to dig through Java source myself if it will help, but if so, = I could use a little guidance getting started. Thanks, Andrew ------=_NextPart_000_0226_01CEAF0F.4083C1F0--