我尝试安装的每个插件都抛出一个错误,提示它找不到清单。没错,文件不存在。我正在尝试从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'
我该如何解决这些错误?
答案 0 :(得分:9)
得到答案后,这个了不起的社区制作了一个脚本来对其进行修补。
在脚本文件夹中创建一个名为
的脚本patch-android-studio-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; };
};
然后添加这些挂钩
<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>
接下来,删除您的plugins and platform文件夹。然后运行cordova platform add android
,这将重新创建平台并正确添加插件。
第二部分是不使用图片选择器插件。
2019年3月更新-从Cordova Android版本8开始,似乎不再需要它了,实际上会引起问题。
答案 1 :(得分:2)
根据文档(cordova android 7,AndroidManifest.xml
的文件路径已更改。因此,您必须将所有插件更新为支持android 7的版本!
答案 2 :(得分:0)
在您的config.xml文件下面
referrerClient.startConnection(new InstallReferrerStateListener() {
@Override
public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) {
case InstallReferrerClient.InstallReferrerResponse.OK:
ReferrerDetails response = null;
try {
response = referrerClient.getInstallReferrer();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
@Override
public void onInstallReferrerServiceDisconnected() {
}
});
添加此行
<platform name="android">