androidcordovaibm-mobilefirst

Cordova Build Error : Camera Plugin missing android.support.v4 Library dependencies


Unable to build an IBM MobileFirst 7.1 based Cordova Android App. Recently upgraded the mobilefirst cli version to 7.1.0.00.20180302-0537

Upon adding the camera plugin(org.apache.cordova.camera), android build fails with the following error mention in log below. Looking at the error it looks like the plugin now required the support library but doesn't have it indicated as a dependency. Not quite sure of what needs to be done to resolve this.

-compile:
[javac] Compiling 47 source files to /Users/dev/MFPApp/platforms/android/ant-build/classes
[javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
[javac] /Users/dev/MFPApp/platforms/android/src/org/apache/cordova/camera/CameraLauncher.java:56: error: package android.support.v4.content does not exist
[javac] import android.support.v4.content.FileProvider;
[javac]                                  ^
[javac] /Users/dev/MFPApp/platforms/android/src/org/apache/cordova/camera/CordovaUri.java:25: error: package android.support.v4.content does not exist
[javac] import android.support.v4.content.FileProvider;
[javac]                                  ^
[javac] /Users/dev/MFPApp/platforms/android/src/org/apache/cordova/camera/CameraLauncher.java:278: error: cannot find symbol
[javac]         this.imageUri = new CordovaUri(FileProvider.getUriForFile(cordova.getActivity(),
[javac]                                        ^
[javac]   symbol:   variable FileProvider
[javac]   location: class CameraLauncher
[javac] /Users/dev/MFPApp/platforms/android/src/org/apache/cordova/camera/CameraLauncher.java:732: error: cannot find symbol
[javac]                         Uri tmpFile = FileProvider.getUriForFile(cordova.getActivity(),
[javac]                                       ^
[javac]   symbol:   variable FileProvider
[javac]   location: class CameraLauncher
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 4 errors
[javac] 3 warnings

Environment Information

OS: darwin x64
Release: 17.7.0
System Memory: 5112 MB free out of 16384 MB
Node: v0.10.36
MobileFirst CLI: 7.1.0.00.20180302-0537
Cordova:6.3.0

Plugin Information

cordova-plugin-mfp 7.1.0 "IBM MobileFirst Platform Foundation"
cordova-plugin-mfp-jsonstore 7.1.0 "IBM MobileFirst Platform Foundation - JSONStore"
cordova-plugin-mfp-push 7.1.0 "IBM MobileFirst Platform Foundation - Push Notifications"
org.apache.cordova.battery-status 0.2.12 "Battery"
org.apache.cordova.camera 0.3.4 "Camera"
org.apache.cordova.console 0.2.12 "Console"
org.apache.cordova.device 0.2.13 "Device"
org.apache.cordova.device-motion 0.2.11 "Device Motion"
org.apache.cordova.dialogs 0.2.11 "Notification"
org.apache.cordova.geolocation 0.3.11 "Geolocation"
org.apache.cordova.globalization 0.3.3 "Globalization"
org.apache.cordova.inappbrowser 0.5.4 "InAppBrowser"
org.apache.cordova.network-information 0.2.14 "Network Information"
org.apache.cordova.splashscreen 0.3.5 "Splashscreen"
org.apache.cordova.statusbar 0.1.9 "StatusBar"
org.apache.cordova.vibration 0.3.12 "Vibration"

Solution

  • You may be facing a known issue that starts from Android N. This has been fixed in iFix 7.1.0.0-MFPF-IF201802160539

    Alternatively, try the steps mentioned in this link:

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

    The steps are:

      <provider android:authorities="{PACKAGE_ID}.provider" android:exported="false" 
       android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider"> 
       <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" /> 
      </provider>
    

    Where {PACKAGE_ID} is replaced with the Android Package ID of your project.

    Update the config.xml file.

    Where {PACKAGE_ID} is replaced by the Android Package ID of your project.