Upgrading the PhoneGap Library Used by the Android Hybrid Web Container

SAP Mobile Platform includes the Cordova (PhoneGap) 2.0 libraries. Follow these steps if you want to upgrade the Android Hybrid Web Container to a more recent version of the Cordova library.

This procedure describes upgrading the Cordova library from version 2.0.0 to version 2.9.0. The steps to upgrade to other versions differ slightly. Since the Hybrid Web Container template project does not include the source code for building HWCLib.jar, the ability to upgrade Cordova to newer versions is limited, and certain new Cordova features may not work properly in Hybrid Web Container project.
Note: Upgrading the Hybrid Web Container container to use Cordova 3.0.0 is not supported because the Hybrid Web Container project does not work with Cordova 3.0.0 CLI.
  1. Download phonegap 2.9.0 from phonegap.com, and unzip it to a local folder.
  2. Open Eclipse and import the HWC template project.
  3. Expand the HWC template project, and delete the cordova-2.0.0.jar file from the libs folder. Copy the cordova-2.9.0.jar file from the unzipped phonegap2.9.0 \lib\android\ folder, and copy it to the libs folder.
  4. Right click the Hybrid Web Container project and click the Properties menu. Select Java Build Path > Libraries.
  5. Select the cordova-2.0.0.jar file, then select Remove, to remove the old jar file.
  6. Select Add JARs… and expand the HybridWebContainer\libs node. Select the new cordova-2.9.0.jar file, and click OK to confirm the selection.
  7. Select OK to close the “Properties” dialog.
  8. Update the private void initWebView() method.
    private void initWebView() calls the super.loadUrlWithData(sBaseURL, abData) Cordova method, which no longer exists in cordova-2.9.0. Change this method to call the super.loadUrl(sBaseURL) method instead.

    Open the UiHybridAppContainer.java class and navigate to the private void initWebView() method and make this change:.

    // PhoneGap Change: We must call through PhoneGap to load the URL
    if ( USE_PHONEGAP )
    {
       // PhoneGap may timeout loading the web page
       super.setIntegerProperty( "loadUrlTimeoutValue", 300000 );
    
       // PhoneGap will load the URL
       super.loadUrl(sBaseURL );
    } 
    else
    {
       m_oWebView.loadDataWithBaseURL( sBaseURL, new String( abData ), null, "utf-8", null );
    }
    
  9. Clean the HWC project and have Eclipse build the HWC project.
  10. If the cordova.js file is used in your HybridApp.js app, you must also update cordova.js to the one provided with the new cordova library.