Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
9 replies Latest Post - ‏2012-10-15T06:21:58Z by stephen_zhang
Capstan
Capstan
18 Posts
ACCEPTED ANSWER

Pinned topic Cordova showcase problem on Android

‏2012-10-05T18:03:21Z |
I imported the Cordova showcase sample project (Module 60.1), built it for Android and tried running it in the browser simulator. The UI is broken.

Looking at it in Firebug I see some load errors. Neither of these files are found.

http://localhost:8080/apps/services/preview/cordovashowcase/android/1.0/default/dojo/dojox/mobile/themes/common/FixedSplitter.css

http://localhost:8080/apps/services/preview/cordovashowcase/android/1.0/default/dojo/dojo/fx/Toggler.js

I did a search through the project and don't see them anywhere. There is no dojo subdirectory in the main project tree. I guess I could pull those files out of the dojo mobile tree from another project and insert them somewhere, but I don't know where they should go.
  • Capstan
    Capstan
    18 Posts
    ACCEPTED ANSWER

    Re: Cordova showcase problem on Android

    ‏2012-10-07T17:12:45Z  in response to Capstan
    Doing some further searching I find code in the file .../dojo/dojox/mobile/migrationAssist.js that references FixedSplitter.css

    this.checkFixedSplitter = function(/*Widget*/ w){
    // FixedSplitter.css has been moved from the themes/common folder
    // to a device theme folder such as themes/android.

    I searched around through the Dojo sources for various files that were showing up as missing in Firebug when I tried to get this project running in the Mobile Simulator and pasted them into places that eventually caused the load errors to go away. But it never did run successfully in the Simulator. I did get it working on my Android phone however.

    When was this showcase written? I'm concerned that this code example and possibly some others are out of date relative to the current version of Worklight and Dojo.
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: Cordova showcase problem on Android

      ‏2012-10-07T18:47:00Z  in response to Capstan
      Um, the showcase seems to be a mix of:

      http://dojotoolkit.org/features/mobile (click 'see in action')
      http://demos.dojotoolkit.org/demos/mobileGallery/demo-iphone.html
      and
      https://github.com/apache/incubator-cordova-mobile-spec

      It didn't work on the Mobile Simulator for me either, worked find in the iPad simulator though.

      I could be wrong but I think it was written before IBM acquired Worklight and then it was updated for WL v5.

      I will let people know it could be out of data, thanks for telling us.

      However, I got Cordova's mobile spec project to run everything relatively well:

      git clone git://github.com/apache/incubator-cordova-mobile-spec.git
      git checkout 0335483d52158d56f77e810f763deb9998e97ff0

      (that checkout is when they used Cordova 1.7, the master/main branch uses Cordova 2.0)

      New WL Hybrid App > dropped every folder under common/
      Renamed app-name.html to app-name.html.bkp
      Renamed index.html to app-name.html
      Changed the third line of cordova.js to:
      
      var cordovaPath = scripts[scripts.length - 1].src.replace(
      'cordova.js', 
      'wlclient/js/cordova.js');
      


      (we want to use the version of cordova.js that WL ships, it's 1.6.1 if I recall correctly)

      New WL Environment > [x] Android, [x] iPhone > Build All and Deploy
      Open http://localhost:8080/console/ (assuming that's where the WL Server is running)
      Click on the eye icon next the the Android or iOS environment

      Accelerometer test:
      http://f.cl.ly/items/360L330w1y203s2S2Q2F/Screen%20Shot%202012-10-07%20at%201.33.52%20PM.png

      Main screen:
      http://f.cl.ly/items/3N362D3u3a3O2d1S3b3X/Screen%20Shot%202012-10-07%20at%201.29.38%20PM.png

      Compass test:
      http://f.cl.ly/items/3V1t2m3s2J1J1o0F1W15/Screen%20Shot%202012-10-07%20at%201.28.58%20PM.png

      I don't know if that's useful or not, but it's a way to get most of Cordova's API tests into a Worklight Application.
      • Capstan
        Capstan
        18 Posts
        ACCEPTED ANSWER

        Re: Cordova showcase problem on Android

        ‏2012-10-08T01:39:58Z  in response to SystemAdmin
        Thanks for having a look at this. While the Cordova showcase does install on my Android phone I am finding that many of the test cases do not work. I'll look into it further but I didn't expect this kind of problem.

        The ability to access native phone features is critically important for any kind of significant commercial app. I encourage the development team to completely wring out the Cordova examples and ensure that they are completely functional.
        • SystemAdmin
          SystemAdmin
          2327 Posts
          ACCEPTED ANSWER

          Re: Cordova showcase problem on Android

          ‏2012-10-08T02:42:57Z  in response to Capstan
          I've sent an email out to the appropriate people and it's being looked at.

          On a semi-related note, I highly suggest you take a look at Apache Cordova's documentation for 1.6.1:
          http://docs.phonegap.com/en/1.6.1/index.html

          For example, open the link titled 'Notification' and select 'alert':
          http://docs.phonegap.com/en/1.6.1/cordova_notification_notification.md.html#notification.alert

          Scroll-down to the 'Full Example' header and copy the contents of the second script tag and the contents of the body tag into your Worklight Application.

          It should work fine on any device running the Worklight Application, assuming it's listed under 'supported platforms'. If it doesn't it's a serious bug and you should post it here on the forums so we can fix it as soon as possible.

          I suspect this 'vanilla' javascript approach to testing the various Apache Cordova methods will be far less error prone than the dojo app.
          • Capstan
            Capstan
            18 Posts
            ACCEPTED ANSWER

            Re: Cordova showcase problem on Android

            ‏2012-10-11T16:37:06Z  in response to SystemAdmin
            Running the Cordova Showcase on my phone with logcat showed that a lot of permissions were not set in the android manifest. Page 14 of Module 60_3 does say to edit the manifest and enable everything plus the kitchen sink, apparently I missed that. Not sure why they don't come already enabled with the project sources, but whatever. Now the showcase runs as expected.
            • SystemAdmin
              SystemAdmin
              2327 Posts
              ACCEPTED ANSWER

              Re: Cordova showcase problem on Android

              ‏2012-10-11T17:36:00Z  in response to Capstan
              Good suggestion Capstan, I'll pass it on. Thanks.

              Barbara Hampson, Manager, IBM Worklight
              • stephen_zhang
                stephen_zhang
                8 Posts
                ACCEPTED ANSWER

                Re: Cordova showcase problem on Android

                ‏2012-10-15T06:21:58Z  in response to SystemAdmin
                Originally, WL will open all permissions in Android manifest. But for security reason, it only open a small part of the permissions in the generated Android manifest. Users can modify the permissions manually but that is not quite convenient for just importing samples and click to run. We tended to enable the modified permission in the generated Android code but it creates some problem when it is imported into Eclipse as a project.
                We need to fix the project import problem with native directory before enabling the Android permissions in samples by default.
  • stephen_zhang
    stephen_zhang
    8 Posts
    ACCEPTED ANSWER

    Re: Cordova showcase problem on Android

    ‏2012-10-11T07:14:16Z  in response to Capstan
    Dojo mobile dynamically load these resources when the load mechanism is set to synchronous. They are not used by any part of the sample application and are not recogized by dojo's builder when packing for an optimized application. But it might broken down the mobile simulator running on desktop browsers. It works fine on mobile devices even though same load error is reported on devices.

    We need to fix that with dojo or mobile simulator.
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: Cordova showcase problem on Android

      ‏2012-10-11T16:28:42Z  in response to stephen_zhang
      Also, a defect has been opened to track this issue.

      Barbara Hampson, Manager, IBM Worklight