Android build error upon upgrading Cordova's camera plugin
Solution 1
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]
Solution 2
I ran into the same problem today. I got it fixed by re-installing the plugin cordova-plugin-compat
.
Due to the dependencies I used --force.
cordova plugin remove cordova-plugin-compat --force
cordova plugin add cordova-plugin-compat
Solution 3
I was also getting error from camera plugin 2.3.1. It is because of the dependency on the cordova-plugin-compat to get the application id. Removing cordova-plugin-compat and installing 1.1.0, didn't work for me.
To fix this remove this code from "src/android/CameraLauncher.java":
140 - this.applicationId = (String) BuildHelper.getBuildConfigValue(cordova.getActivity(), "APPLICATION_ID");
141 - this.applicationId = preferences.getString("applicationId", this.applicationId);
and add:
140 + this.applicationId = cordova.getActivity().getPackageName();
Solution 4
You should upgrade cordova-plugin-camera to version 1.1
Solution 5
I got the exact same error. This is actually caused by an old version of the cordova-plugin-compat plugin (1.0), by upgrading to version 1.1 (latest), it will work.
Here is what I did,
Remove all platforms
cordova platform remove android
cordova platform remove ios
Remove old plugin and add new
cordova plugin remove cordova-plugin-compat
cordova plugin add cordova-plugin-compat
Add all platforms back
cordova platform add android
cordova platform add ios
Re-compile and everything works!
user2934433
Updated on July 25, 2022Comments
-
user2934433 almost 2 years
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.
-
user2934433 over 7 yearsI am trying to get the latest version of plugin do not want to downgrade the version
-
user2934433 over 7 yearscould you provide me with versions of plugins you are using.
-
Nagy Istvan over 7 yearsit's a good practice to keep all plugins up to date, and the SKD tools too
-
Dulanjana Wickramatantri about 7 yearsthis one worked for me as well. But I'm using visual studio 2015 cordova tools. I had to go through tough process to remove and adding these plugins. I wrote a blog post on this on my blog. Please follow the bellow link. guntucomputerhacks.blogspot.com.au/2017/04/…
-
Mark about 7 yearsI installed camera plugin v2.4.0, then my builds failed. Sadly, the above process failed for me (when I did do the above, afterwards I was prompted to install a cordova update). When I removed the camera 2.4.0 plugin, my builds would work again. I will hunt around to see if there is another suggestion/fix.
-
Valerio Gentile almost 7 yearsIf you are using "Visual Studio Tools for Apache Cordova" you might need to run the above commands in the "Package Manager Console" and if you get an error saying "Current working directory is not a Cordova-based project" then you just need to change your current working directory by using a DOS command. In my case, I run DIR to figure out which one was my current working directory and then I run CD App to move to the Cordova-based project directory. After this, the solution listed in this answer worked perfectly fine with no errors.
-
0bj3ct over 6 yearsWorked for me, Thank you!
-
Manish Pradhan over 6 yearsWorked for me too. I had installed 1.2.0 version of the compat plugin which seems to give the same error. Then I uninstalled and installed the 1.1.0 and the errors went away. Thx.