IBM Support

Using Window.Open to open InAppBrowser (Cordova) results in an Android exception and crashes the application

Troubleshooting


Problem

You might experience an application crash when you use the Cordova InAppBrowser plug-in in a hybrid application with an Android environment.

Symptom

The following Android exception might be seen:


    E/AndroidRuntime(28398): FATAL EXCEPTION: main
    E/AndroidRuntime(28398): android.content.res.Resources$NotFoundException: Resource ID #0x0
    E/AndroidRuntime(28398): at android.content.res.Resources.getValue(Resources.java:1883)
    E/AndroidRuntime(28398): at android.content.res.Resources.getDrawable(Resources.java:1520)
    E/AndroidRuntime(28398): at org.apache.cordova.inappbrowser.InAppBrowser$5.run(InAppBrowser.java:500)
    E/AndroidRuntime(28398): at android.app.Activity.runOnUiThread(Activity.java:4785)
    E/AndroidRuntime(28398): at org.apache.cordova.inappbrowser.InAppBrowser.showWebPage(InAppBrowser.java:654)
    E/AndroidRuntime(28398): at org.apache.cordova.inappbrowser.InAppBrowser$1.run(InAppBrowser.java:149)

Cause

Three PNG files are missing from the \native\res\drawable-hdpi directory of your Worklight V6.2 project.

Resolving The Problem

The current workaround is to create a stand-alone Cordova 3.4 Android application with the Cordova Command Line Interface.

This workaround does not replace your Worklight application, but you can generate the missing resources.

Workaround Procedure:

  1. Navigate to the Android Platform Guide.

  2. In the Requirements and Support section, follow the steps to include the tools and platform-tools directories for the Android SDK in your PATH environment and to enable Java and Ant.

  3. Navigate to the Command-Line Interface.

  4. Follow the steps in the Prerequisites section.

  5. Execute the following commands:
    $ cordova create hello com.example.hello "HelloWorld"

    $ cd hello

    $ cordova platform add android

    $ cordova plugin add org.apache.cordova.inappbrowser

    $ cordova build

  6. Navigate back to the Android Platform Guide.

  7. Follow the steps in the Open a Project in the SDK section.

  8. Copy the following files from \hello\platforms\android\res\drawable-hdpi directory into the \native\res\drawable-hdpi directory of your Worklight V6.2 project:
    ic_action_next_item.png
    ic_action_previous_item.png
    ic_action_remove.png

This problem is resolved by APAR PI21653.

[{"Product":{"code":"SSZH4A","label":"IBM Worklight"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Application Development","Platform":[{"code":"PF003","label":"Android"}],"Version":"6.2","Edition":"Consumer;Enterprise","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
17 June 2018

UID

swg21681060