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 E3A8510932 for ; Thu, 12 Sep 2013 07:01:19 +0000 (UTC) Received: (qmail 43095 invoked by uid 500); 12 Sep 2013 07:01:19 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 42545 invoked by uid 500); 12 Sep 2013 07:01:09 -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 42529 invoked by uid 99); 12 Sep 2013 07:01:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Sep 2013 07:01:06 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [173.201.193.110] (HELO p3plsmtpa08-09.prod.phx3.secureserver.net) (173.201.193.110) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Sep 2013 07:00:59 +0000 Received: from chiron ([50.47.43.35]) by p3plsmtpa08-09.prod.phx3.secureserver.net with id Q70E1m00H0lXdyA0170EUd; Thu, 12 Sep 2013 00:00:15 -0700 Message-ID: <42CCE7CA40D04A2BBAA7BED29C0CEA83@ECPCorp.local> From: "dev at watch2web.com" To: , References: <63A892C02F1840E18101EEEC9161E92C@ECPCorp.local> Subject: Re: addJavascriptInterface fails on Android API levels 17 and 18 (4.2.2 and 4.3) Date: Thu, 12 Sep 2013 00:00:14 -0700 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit 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 My app is a Cordova app -- Cordova 3.0.0, as I said. I added just a few little JavascriptInterface methods because they did so little that writing a full-on plugin seemed like overkill. It has all worked very nicely until API 17, and I have not come across something that says it is forbidden to create your own little JSI when using Cordova. If it is forbidden, please tell me, and I apologize for my ignorance. I am using JDK 1.6. According to docs, it has full support for annotations, and if it didn't, wouldn't this have failed on API levels 16 and lower? I guess your point is that I can probably demonstrate the same failure in an app that doesn't use Cordova, and therefore, my problem is irrelevant. You may be right about the first part, and of course I respect your judgment re. relevance. But I imagine the same thing could be said about a lot of issues you have had to deal with. I was hoping to get some direction from experts who have had to deal with whatever change in Android 4.2.2 (API 17) occurred that seems to be connected here. ----- Original Message ----- From: "Joe Bowser" To: "dev" Sent: Wednesday, 11 September, 2013 16:59 Subject: Re: addJavascriptInterface fails on Android API levels 17 and 18 (4.2.2 and 4.3) What does this have to do with Cordova? It looks like you're building your own bridge on Android. Make sure that your Java version that you're building with supports annotations. If not, you won't be able to add the Javascript Interface. On Wed, Sep 11, 2013 at 4:52 PM, dev at watch2web.com wrote: > 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 == undefined) console.log("javascript interface is > undefined"); > else if (window.MyJSI == null) console.log("javascript interface is > null"); > else if (typeof(window.MyJSI) == '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 <= 16) and "bad" (Galaxy S4, API level >= 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. > > 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. > > https://issues.apache.org/jira/browse/CB-1879?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501660#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