Search code examples
androidcordovaionic-frameworkcordova-plugins

Android build error upon upgrading Cordova's camera plugin


I am getting build error after updating cordova camera plugin from 2.1.1 to 2.3.1.

Version details:

cordova version: 6.3.1,
cordova-plugin-camera 2.1.1 "Camera"

What I'm doing:

cordova plugin remove cordova-plugin-camera --save
cordova plugin add cordova-plugin-camera --save

I see the config.xml file has been updated to:

<plugin name="cordova-plugin-camera" spec="~2.3.1" />

When I build cordova android build I get the following error:

Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
warning: string 'menu_settings' has no default translation.

platforms\android\src\org\apache\cordova\camera\CameraLauncher.java:32:
    error: cannot find symbol

import org.apache.cordova.BuildHelper;
symbol:   class BuildHelper
location: package org.apache.cordova
platforms\android\src\org\apache\cordova\camera\CameraLauncher.java:140:
    error: cannot find symbol
this.applicationId = (String)
BuildHelper.getBuildConfigValue(cordova.getActivity(), "APPLICATION_ID");
                                  ^
symbol:   variable BuildHelper
location: class CameraLauncher
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.

Solution

  • We solved this by forcing the install of version 1.1.0.

    Here's the commands we ran from the CLI:

    cordova plugin remove cordova-plugin-compat --force
    cordova plugin add [email protected]