I am getting build error after updating cordova camera plugin from 2.1.1 to 2.3.1. Below are the version details
在将cordova摄像头插件从2.1.1更新到2.3.1之后,我就有了构建错误。下面是版本的详细信息。
cordova version: 6.3.1, cordova-plugin-camera 2.1.1 "Camera". Below are the steps I am followin
cordova版本:6.3.1,cordova-plugin- Camera 2.1.1“Camera”。下面是我遵循的步骤
cordova plugin remove cordova-plugin-camera --save
cordova plugin add cordova-plugin-camera --save
I see the config.xml file has been updated to
我看到配置。xml文件已更新为
When I build cordova android build I get the below 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.
当我构建cordova android构建时,我得到了以下错误:cmd:命令失败,退出码1错误输出:注意:一些输入文件使用或覆盖已弃用的API。注意:使用-Xlint重新编译:不赞成使用细节。注意:一些输入文件使用或覆盖已废弃的API。注意:使用-Xlint重新编译:不赞成使用细节。警告:字符串“menu_settings”没有默认转换。
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
android平台\ \ src \ org \ apache \科尔多瓦\摄像头\ CameraLauncher。错误:无法找到符号导入机构。apache.cordova.buildhelper;类BuildHelper位置:package org.apache。科尔多瓦平台android科尔多瓦\ src \ org \ apache \ \ \摄像头\ CameraLauncher。错误:找不到这个符号。applicationId = (String) BuildHelper.getBuildConfigValue(cordova.getActivity(),“APPLICATION_ID”);^符号:变量BuildHelper位置:类CameraLauncher注意:某些输入文件使用或覆盖一个废弃的API。注意:使用-Xlint重新编译:不赞成使用细节。注意:有些输入文件使用未检查或不安全的操作。注意:使用-Xlint重新编译:未检查细节。2错误
FAILURE: Build failed with an exception.
失败:构建失败,但有一个例外。
-
What went wrong: Execution failed for task ':compileDebugJavaWithJavac'.
错误所在:任务执行失败: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.
尝试:使用—stacktrace选项运行,以获取堆栈跟踪。使用-info或- debug选项运行,以获得更多日志输出。
6 个解决方案
#1
33
We solved this by forcing the install of version 1.1.0.
我们通过强制安装1.1.0版本解决了这个问题。
Here's the commands we ran from the CLI:
下面是我们从CLI中运行的命令:
cordova plugin remove cordova-plugin-compat --force
cordova plugin add cordova-plugin-compat@1.1.0
#2
20
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-compat来修复它。由于我使用的依赖——武力。
cordova plugin remove cordova-plugin-compat --force
cordova plugin add cordova-plugin-compat
#3
3
You should upgrade cordova-plugin-camera to version 1.1
您应该将cordova-plugin-camera升级到1.1版本
#4
2
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.
我得到了相同的错误。这实际上是由旧版本的cordova-plugin-compat插件(1.0)引起的,通过升级到1.1版(最新版本),它将会工作。
Here is what I did,
这是我所做的,
-
Remove all platforms
删除所有平台
cordova platform remove android
科尔多瓦平台删除安卓
cordova platform remove ios
科尔多瓦ios平台删除
-
Remove old plugin and add new
删除旧插件并添加新插件
cordova plugin remove cordova-plugin-compat
科尔多瓦插件删除cordova-plugin-compat
cordova plugin add cordova-plugin-compat
科尔多瓦插件添加cordova-plugin-compat
-
Add all platforms back
添加所有平台回
cordova platform add android
科尔多瓦android平台添加
cordova platform add ios
科尔多瓦ios平台添加
-
Re-compile and everything works!
编译和一切工作!
#5
2
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.
摄像头插件2.3.1也有错误。因为依赖于cordova-plugin-compat来获取应用程序id,删除cordova-plugin-compat并安装1.1.0对我来说并不是件好事。
To fix this remove this code from "src/android/CameraLauncher.java":
要修复此问题,请从“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();
#6
0
I have made changes to the method below.
我对下面的方法做了修改。
// intiatiate you action accordingly
if (action.equals("takePicture")) {
this.srcType = CAMERA;
this.destType = FILE_URI;
this.saveToPhotoAlbum = false;
this.targetHeight = 0;
this.targetWidth = 0;
this.encodingType = JPEG;
this.mediaType = PICTURE;
this.mQuality = 50;
//
this.destType = args.getInt(1);
this.srcType = args.getInt(2);
this.mQuality = args.getInt(0);
this.targetWidth = args.getInt(3);
this.targetHeight = args.getInt(4);
this.encodingType = args.getInt(5);
this.mediaType = args.getInt(6);
this.allowEdit = args.getBoolean(7);
this.correctOrientation = args.getBoolean(8);
this.saveToPhotoAlbum = args.getBoolean(9);
// If the user specifies a 0 or smaller width/height
// make it -1 so later comparisons succeed
if (this.targetWidth < 1) {
this.targetWidth = -1;
}
if (this.targetHeight < 1) {
this.targetHeight = -1;
}
if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 &&
!this.correctOrientation && this.encodingType == PNG && this.srcType == CAMERA) {
this.encodingType = JPEG;
}
try {
if (this.srcType == CAMERA) {
this.callTakePicture(destType, encodingType);
}
else if ((this.srcType == PHOTOLIBRARY) || (this.srcType == SAVEDPHOTOALBUM)) {
// FIXME: Stop always requesting the permission
if(!PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
PermissionHelper.requestPermission(this, SAVE_TO_ALBUM_SEC, Manifest.permission.READ_EXTERNAL_STORAGE);
} else {
this.getImage(this.srcType, destType, encodingType);
}
}
}
catch (IllegalArgumentException e)
{
callbackContext.error("Illegal Argument Exception");
PluginResult r = new PluginResult(PluginResult.Status.ERROR);
callbackContext.sendPluginResult(r);
return true;
}
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
return false;
}
#1
33
We solved this by forcing the install of version 1.1.0.
我们通过强制安装1.1.0版本解决了这个问题。
Here's the commands we ran from the CLI:
下面是我们从CLI中运行的命令:
cordova plugin remove cordova-plugin-compat --force
cordova plugin add cordova-plugin-compat@1.1.0
#2
20
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-compat来修复它。由于我使用的依赖——武力。
cordova plugin remove cordova-plugin-compat --force
cordova plugin add cordova-plugin-compat
#3
3
You should upgrade cordova-plugin-camera to version 1.1
您应该将cordova-plugin-camera升级到1.1版本
#4
2
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.
我得到了相同的错误。这实际上是由旧版本的cordova-plugin-compat插件(1.0)引起的,通过升级到1.1版(最新版本),它将会工作。
Here is what I did,
这是我所做的,
-
Remove all platforms
删除所有平台
cordova platform remove android
科尔多瓦平台删除安卓
cordova platform remove ios
科尔多瓦ios平台删除
-
Remove old plugin and add new
删除旧插件并添加新插件
cordova plugin remove cordova-plugin-compat
科尔多瓦插件删除cordova-plugin-compat
cordova plugin add cordova-plugin-compat
科尔多瓦插件添加cordova-plugin-compat
-
Add all platforms back
添加所有平台回
cordova platform add android
科尔多瓦android平台添加
cordova platform add ios
科尔多瓦ios平台添加
-
Re-compile and everything works!
编译和一切工作!
#5
2
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.
摄像头插件2.3.1也有错误。因为依赖于cordova-plugin-compat来获取应用程序id,删除cordova-plugin-compat并安装1.1.0对我来说并不是件好事。
To fix this remove this code from "src/android/CameraLauncher.java":
要修复此问题,请从“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();
#6
0
I have made changes to the method below.
我对下面的方法做了修改。
// intiatiate you action accordingly
if (action.equals("takePicture")) {
this.srcType = CAMERA;
this.destType = FILE_URI;
this.saveToPhotoAlbum = false;
this.targetHeight = 0;
this.targetWidth = 0;
this.encodingType = JPEG;
this.mediaType = PICTURE;
this.mQuality = 50;
//
this.destType = args.getInt(1);
this.srcType = args.getInt(2);
this.mQuality = args.getInt(0);
this.targetWidth = args.getInt(3);
this.targetHeight = args.getInt(4);
this.encodingType = args.getInt(5);
this.mediaType = args.getInt(6);
this.allowEdit = args.getBoolean(7);
this.correctOrientation = args.getBoolean(8);
this.saveToPhotoAlbum = args.getBoolean(9);
// If the user specifies a 0 or smaller width/height
// make it -1 so later comparisons succeed
if (this.targetWidth < 1) {
this.targetWidth = -1;
}
if (this.targetHeight < 1) {
this.targetHeight = -1;
}
if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 &&
!this.correctOrientation && this.encodingType == PNG && this.srcType == CAMERA) {
this.encodingType = JPEG;
}
try {
if (this.srcType == CAMERA) {
this.callTakePicture(destType, encodingType);
}
else if ((this.srcType == PHOTOLIBRARY) || (this.srcType == SAVEDPHOTOALBUM)) {
// FIXME: Stop always requesting the permission
if(!PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
PermissionHelper.requestPermission(this, SAVE_TO_ALBUM_SEC, Manifest.permission.READ_EXTERNAL_STORAGE);
} else {
this.getImage(this.srcType, destType, encodingType);
}
}
}
catch (IllegalArgumentException e)
{
callbackContext.error("Illegal Argument Exception");
PluginResult r = new PluginResult(PluginResult.Status.ERROR);
callbackContext.sendPluginResult(r);
return true;
}
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
return false;
}