我尝试安装的每个插件都会抛出错误,说它无法找到清单.这是真的,文件不存在.我试图升级6.4,因为6.4似乎不支持Android上的64位CPU,而无需手动更改构建清单.
Failed to install 'cordova-plugin-geolocation': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-file': Error: ENOENT: no such file or directory, open 'C:\..\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-google-analytics': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-inappbrowser': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-whitelist': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-network-information': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-sqlite-storage': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-android-permissions': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-statusbar': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-device': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
Failed to install 'cordova-plugin-image-picker': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'
我该如何解决这些错误?
得到了答案,这个神奇的社区制作了一个脚本来修补它.
在脚本文件夹中创建一个名为的脚本
补丁Android的工作室check.js
把它放在里面
/**
* This hook overrides a function check at runtime. Currently, cordova-android 7+ incorrectly detects that we are using
* an eclipse style project. This causes a lot of plugins to fail at install time due to paths actually being setup
* for an Android Studio project. Some plugins choose to install things into 'platforms/android/libs' which makes
* this original function assume it is an ecplise project.
*/
module.exports = function(context) {
if (context.opts.cordova.platforms.indexOf('android') < 0) {
return;
}
const path = context.requireCordovaModule('path');
const androidStudioPath = path.join(context.opts.projectRoot, 'platforms/android/cordova/lib/AndroidStudio');
const androidStudio = context.requireCordovaModule(androidStudioPath);
androidStudio.isAndroidStudioProject = function() { return true; };
};
Run Code Online (Sandbox Code Playgroud)
然后添加这些钩子
<platform name="android">
<hook src="scripts/patch-android-studio-check.js" type="before_plugin_install" />
<hook src="scripts/patch-android-studio-check.js" type="before_plugin_install" />
<hook src="scripts/patch-android-studio-check.js" type="before_plugin_add" />
<hook src="scripts/patch-android-studio-check.js" type="before_build" />
<hook src="scripts/patch-android-studio-check.js" type="before_run" />
<hook src="scripts/patch-android-studio-check.js" type="before_plugin_rm" />
</platform>
Run Code Online (Sandbox Code Playgroud)
接下来,删除插件和平台文件夹.然后运行cordova platform add android,这将重新创建平台并正确添加插件.
第二部分是不使用图像选择器插件.
| 归档时间: |
|
| 查看次数: |
2493 次 |
| 最近记录: |