Preparing a project that uses the Cordova camera plug-in with the Android platform

You must complete extra steps for the Cordova camera plug-in to work correctly with your IBM MobileFirst™ Platform Foundation Cordova app for the Android platform.

About this task

Starting with Android N, the Cordova camera plug-in requires a fix that enables the file URI of the photo to be accessed by the camera plug-in. The fix requires some extra setup steps for the camera plug-in to work correctly. You must complete these steps when you create a Cordova app that uses the Cordova camera plug-in with the Android platform or when you modify an existing Cordova app to use the camera plug-in. If you do not complete the steps, your app crashes when it starts, and returns the following error messages:
java.lang.RuntimeException: Unable to get provider 
java.lang.ClassNotFoundException: Didn't find class ""

Complete the following steps to prepare the project:


  1. Add the android-support-v4.jar file to your project.
    1. In a file explorer, browse to your Android SDK directory, which is where your Android SDK Manager downloads the updates.
      Tip: If you are using Android Studio, you can open the SDK Manager from the toolbar.
    2. If it is not already installed, install the Android Support Repository in your Android environment.
    3. Browse to extras/android/m2repository/com/android/support/support-core-utils.
    4. Select version 24.2.0, or higher, of the support-core-utils repository.
    5. Extract the classes.jar file from the support-core-utils-24.2.0.aar package.
      Tip: If you do not have a file archive tool, you can change the .aar file extension to .zip to extract the classes.jar file.
    6. Add the classes.jar file to the libs directory of your Android platform.
  2. Update the AndroidManifest.xml file.
    1. Open the AndroidManifest.xml file that is in the platforms/android folder.
    2. Add the following lines inside of the ending <application> tag:
      <provider android:authorities="{PACKAGE_ID}.provider" android:exported="false" 
      android:grantUriPermissions="true" android:name=""> 
      <meta-data android:name="" android:resource="@xml/provider_paths" /> 
      Where {PACKAGE_ID} is replaced with the Android Package ID of your project.
    3. Save the AndroidManifest.xml file.
  3. Update the config.xml file.
    1. Open the config.xml file that is in your project folder.
    2. Inside the <platform name="android"> tag, add the following tag:
      <preference name="applicationId" value="{PACKAGE_ID}"/>
      Where {PACKAGE_ID} is replaced by the Android Package ID of your project.
    3. Save the config.xml file.