部署到设备时未加载 cordova 包
Packages for cordova are not loading when deployed to a device
我有一个 Cordova 应用程序,在部署到浏览器或仅加载到浏览器时效果很好。但是,当通过 cordova run android
将应用程序发送到设备时,找不到插件。
使用 Chrome 远程设备检查器,我可以看到插件未能加载到我期望的正常位置。
下面的代码段是 config.xml
一些被删减的项目的副本。
<?xml version='1.0' encoding='utf-8'?>
<widget defaultlocale="en-US" id="---censored---" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps">
<name>---censored---</name>
<description>---censored---</description>
<author email="---censored---" href="---censored---">---censored---</author>
<vs:template-name>BlankJS</vs:template-name>
<content src="index.html" />
<access origin="*" />
<preference name="SplashScreen" value="screen" />
<preference name="windows-target-version" value="10.0" />
<preference name="DisallowOverscroll" value="true" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#fff" />
<allow-navigation href="*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<platform name="android">
<icon density="ldpi" src="res/icons/android/icon-36-ldpi.png" />
<icon density="mdpi" src="res/icons/android/icon-48-mdpi.png" />
<icon density="hdpi" src="res/icons/android/icon-72-hdpi.png" />
<icon density="xhdpi" src="res/icons/android/icon-96-xhdpi.png" />
</platform>
<platform name="ios">
<icon height="180" src="res/icons/ios/icon-60-3x.png" width="180" />
<icon height="60" src="res/icons/ios/icon-60.png" width="60" />
<icon height="120" src="res/icons/ios/icon-60-2x.png" width="120" />
<icon height="76" src="res/icons/ios/icon-76.png" width="76" />
<icon height="152" src="res/icons/ios/icon-76-2x.png" width="152" />
<icon height="40" src="res/icons/ios/icon-40.png" width="40" />
<icon height="80" src="res/icons/ios/icon-40-2x.png" width="80" />
<icon height="57" src="res/icons/ios/icon-57.png" width="57" />
<icon height="114" src="res/icons/ios/icon-57-2x.png" width="114" />
<icon height="72" src="res/icons/ios/icon-72.png" width="72" />
<icon height="144" src="res/icons/ios/icon-72-2x.png" width="144" />
<icon height="29" src="res/icons/ios/icon-small.png" width="29" />
<icon height="58" src="res/icons/ios/icon-small-2x.png" width="58" />
<icon height="50" src="res/icons/ios/icon-50.png" width="50" />
<icon height="100" src="res/icons/ios/icon-50-2x.png" width="100" />
</platform>
<platform name="windows">
<icon height="150" src="res/icons/windows/Square150x150Logo.scale-100.png" width="150" />
<icon height="360" src="res/icons/windows/Square150x150Logo.scale-240.png" width="360" />
<icon height="30" src="res/icons/windows/Square30x30Logo.scale-100.png" width="30" />
<icon height="310" src="res/icons/windows/Square310x310Logo.scale-100.png" width="310" />
<icon height="44" src="res/icons/windows/Square44x44Logo.scale-100.png" width="44" />
<icon height="106" src="res/icons/windows/Square44x44Logo.scale-240.png" width="106" />
<icon height="70" src="res/icons/windows/Square70x70Logo.scale-100.png" width="70" />
<icon height="71" src="res/icons/windows/Square71x71Logo.scale-100.png" width="71" />
<icon height="170" src="res/icons/windows/Square71x71Logo.scale-240.png" width="170" />
<icon height="50" src="res/icons/windows/StoreLogo.scale-100.png" width="50" />
<icon height="120" src="res/icons/windows/StoreLogo.scale-240.png" width="120" />
<icon height="150" src="res/icons/windows/Wide310x150Logo.scale-100.png" width="310" />
<icon height="360" src="res/icons/windows/Wide310x150Logo.scale-240.png" width="744" />
</platform>
<platform name="android">
<splash density="land-hdpi" src="res/screens/android/screen-hdpi-landscape.png" />
<splash density="land-ldpi" src="res/screens/android/screen-ldpi-landscape.png" />
<splash density="land-mdpi" src="res/screens/android/screen-mdpi-landscape.png" />
<splash density="land-xhdpi" src="res/screens/android/screen-xhdpi-landscape.png" />
<splash density="port-hdpi" src="res/screens/android/screen-hdpi-portrait.png" />
<splash density="port-ldpi" src="res/screens/android/screen-ldpi-portrait.png" />
<splash density="port-mdpi" src="res/screens/android/screen-mdpi-portrait.png" />
<splash density="port-xhdpi" src="res/screens/android/screen-xhdpi-portrait.png" />
</platform>
<platform name="ios">
<splash height="480" src="res/screens/ios/screen-iphone-portrait.png" width="320" />
<splash height="960" src="res/screens/ios/screen-iphone-portrait-2x.png" width="640" />
<splash height="1024" src="res/screens/ios/screen-ipad-portrait.png" width="768" />
<splash height="2048" src="res/screens/ios/screen-ipad-portrait-2x.png" width="1536" />
<splash height="768" src="res/screens/ios/screen-ipad-landscape.png" width="1024" />
<splash height="1536" src="res/screens/ios/screen-ipad-landscape-2x.png" width="2048" />
<splash height="1136" src="res/screens/ios/screen-iphone-568h-2x.png" width="640" />
<splash height="1334" src="res/screens/ios/screen-iphone-portrait-667h.png" width="750" />
<splash height="2208" src="res/screens/ios/screen-iphone-portrait-736h.png" width="1242" />
<splash height="1242" src="res/screens/ios/screen-iphone-landscape-736h.png" width="2208" />
</platform>
<platform name="windows">
<splash height="300" src="res/screens/windows/SplashScreen.scale-100.png" width="620" />
<splash height="1920" src="res/screens/windows/SplashScreen.scale-240.png" width="1152" />
<splash height="1920" src="res/screens/windows/SplashScreenPhone.scale-240.png" width="1152" />
</platform>
<vs:toolsetVersion>6.3.1</vs:toolsetVersion>
<preference name="target-device" value="universal" />
<preference name="Orientation" value="default" />
<preference name="Fullscreen" value="True" />
<engine name="android" spec="^6.2.3" />
<engine name="browser" spec="^4.1.0" />
<engine name="ios" spec="~4.2.0" />
<engine name="windows" spec="~4.4.2" />
<plugin name="cordova-plugin-device" spec="^1.1.6" />
<plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" />
<plugin name="cordova-plugin-statusbar" spec="~2.2.3" />
<plugin name="cordova-plugin-whitelist" spec="1.2.2" />
</widget>
Cordova.js 加载得很好,但我无法让插件在浏览器之外加载。
任何方向都会非常赞赏!
编辑
我找到了一些与 TACO 工作原理相关的信息,我相信我可能处于类似于 this.
的情况
您是否尝试通过 cordova plugin add <plugin name>
删除插件并重新添加它们?
什么是 cordova plugin list
输出?
cordova build android -XLint:all
的输出是什么?
检查您是否已将插件导入相应的 html 文件
您的配置似乎缺少一个重要的插件:
<plugin name="cordova-plugin-splashscreen" spec="^3.2.2" />
我的配置是3.2.2,你可以试试最新的4.0.3版本
您还可以检查 plaftorms/android/platform_www/plugins 中是否所有插件都可用:
请问post环境信息运行:
ionic info
ionic serve 会报错吗?
这可能是兼容性问题或权限问题。您还可以确认平台文件夹中不存在未找到的文件吗?
转到平台>android>platform_www>插件
在最坏的情况下,我建议您复制项目文件夹作为备份,转到项目目录删除 node_modules 文件夹, 运行:
npm install
这将更新库。
尝试在 Platforms 下的配置文件中将 Cordova CLI 更改为某个较低版本。
当 Cordova 生成插件时,它会在根目录 plugins
上创建一个文件夹。我们使用我们自己的 Plugins
文件夹来保存一些第 3 方 JS 动画插件。由于 Windows 不区分大小写的性质。浏览器中没有错误 运行。
当部署到 Android 时,Windows 将构建文件,检查 plugins
并匹配 Plugins
并将它们移动到那里。这就是提取的 apk 文件显示正确的原因。当 android 查找文件时,它与 Plugins
不匹配,根本找不到我的插件。
长话短说,不要创建大小写不同于 plugins
的文件夹来存放外部插件。
我有一个 Cordova 应用程序,在部署到浏览器或仅加载到浏览器时效果很好。但是,当通过 cordova run android
将应用程序发送到设备时,找不到插件。
使用 Chrome 远程设备检查器,我可以看到插件未能加载到我期望的正常位置。
下面的代码段是 config.xml
一些被删减的项目的副本。
<?xml version='1.0' encoding='utf-8'?>
<widget defaultlocale="en-US" id="---censored---" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps">
<name>---censored---</name>
<description>---censored---</description>
<author email="---censored---" href="---censored---">---censored---</author>
<vs:template-name>BlankJS</vs:template-name>
<content src="index.html" />
<access origin="*" />
<preference name="SplashScreen" value="screen" />
<preference name="windows-target-version" value="10.0" />
<preference name="DisallowOverscroll" value="true" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#fff" />
<allow-navigation href="*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<platform name="android">
<icon density="ldpi" src="res/icons/android/icon-36-ldpi.png" />
<icon density="mdpi" src="res/icons/android/icon-48-mdpi.png" />
<icon density="hdpi" src="res/icons/android/icon-72-hdpi.png" />
<icon density="xhdpi" src="res/icons/android/icon-96-xhdpi.png" />
</platform>
<platform name="ios">
<icon height="180" src="res/icons/ios/icon-60-3x.png" width="180" />
<icon height="60" src="res/icons/ios/icon-60.png" width="60" />
<icon height="120" src="res/icons/ios/icon-60-2x.png" width="120" />
<icon height="76" src="res/icons/ios/icon-76.png" width="76" />
<icon height="152" src="res/icons/ios/icon-76-2x.png" width="152" />
<icon height="40" src="res/icons/ios/icon-40.png" width="40" />
<icon height="80" src="res/icons/ios/icon-40-2x.png" width="80" />
<icon height="57" src="res/icons/ios/icon-57.png" width="57" />
<icon height="114" src="res/icons/ios/icon-57-2x.png" width="114" />
<icon height="72" src="res/icons/ios/icon-72.png" width="72" />
<icon height="144" src="res/icons/ios/icon-72-2x.png" width="144" />
<icon height="29" src="res/icons/ios/icon-small.png" width="29" />
<icon height="58" src="res/icons/ios/icon-small-2x.png" width="58" />
<icon height="50" src="res/icons/ios/icon-50.png" width="50" />
<icon height="100" src="res/icons/ios/icon-50-2x.png" width="100" />
</platform>
<platform name="windows">
<icon height="150" src="res/icons/windows/Square150x150Logo.scale-100.png" width="150" />
<icon height="360" src="res/icons/windows/Square150x150Logo.scale-240.png" width="360" />
<icon height="30" src="res/icons/windows/Square30x30Logo.scale-100.png" width="30" />
<icon height="310" src="res/icons/windows/Square310x310Logo.scale-100.png" width="310" />
<icon height="44" src="res/icons/windows/Square44x44Logo.scale-100.png" width="44" />
<icon height="106" src="res/icons/windows/Square44x44Logo.scale-240.png" width="106" />
<icon height="70" src="res/icons/windows/Square70x70Logo.scale-100.png" width="70" />
<icon height="71" src="res/icons/windows/Square71x71Logo.scale-100.png" width="71" />
<icon height="170" src="res/icons/windows/Square71x71Logo.scale-240.png" width="170" />
<icon height="50" src="res/icons/windows/StoreLogo.scale-100.png" width="50" />
<icon height="120" src="res/icons/windows/StoreLogo.scale-240.png" width="120" />
<icon height="150" src="res/icons/windows/Wide310x150Logo.scale-100.png" width="310" />
<icon height="360" src="res/icons/windows/Wide310x150Logo.scale-240.png" width="744" />
</platform>
<platform name="android">
<splash density="land-hdpi" src="res/screens/android/screen-hdpi-landscape.png" />
<splash density="land-ldpi" src="res/screens/android/screen-ldpi-landscape.png" />
<splash density="land-mdpi" src="res/screens/android/screen-mdpi-landscape.png" />
<splash density="land-xhdpi" src="res/screens/android/screen-xhdpi-landscape.png" />
<splash density="port-hdpi" src="res/screens/android/screen-hdpi-portrait.png" />
<splash density="port-ldpi" src="res/screens/android/screen-ldpi-portrait.png" />
<splash density="port-mdpi" src="res/screens/android/screen-mdpi-portrait.png" />
<splash density="port-xhdpi" src="res/screens/android/screen-xhdpi-portrait.png" />
</platform>
<platform name="ios">
<splash height="480" src="res/screens/ios/screen-iphone-portrait.png" width="320" />
<splash height="960" src="res/screens/ios/screen-iphone-portrait-2x.png" width="640" />
<splash height="1024" src="res/screens/ios/screen-ipad-portrait.png" width="768" />
<splash height="2048" src="res/screens/ios/screen-ipad-portrait-2x.png" width="1536" />
<splash height="768" src="res/screens/ios/screen-ipad-landscape.png" width="1024" />
<splash height="1536" src="res/screens/ios/screen-ipad-landscape-2x.png" width="2048" />
<splash height="1136" src="res/screens/ios/screen-iphone-568h-2x.png" width="640" />
<splash height="1334" src="res/screens/ios/screen-iphone-portrait-667h.png" width="750" />
<splash height="2208" src="res/screens/ios/screen-iphone-portrait-736h.png" width="1242" />
<splash height="1242" src="res/screens/ios/screen-iphone-landscape-736h.png" width="2208" />
</platform>
<platform name="windows">
<splash height="300" src="res/screens/windows/SplashScreen.scale-100.png" width="620" />
<splash height="1920" src="res/screens/windows/SplashScreen.scale-240.png" width="1152" />
<splash height="1920" src="res/screens/windows/SplashScreenPhone.scale-240.png" width="1152" />
</platform>
<vs:toolsetVersion>6.3.1</vs:toolsetVersion>
<preference name="target-device" value="universal" />
<preference name="Orientation" value="default" />
<preference name="Fullscreen" value="True" />
<engine name="android" spec="^6.2.3" />
<engine name="browser" spec="^4.1.0" />
<engine name="ios" spec="~4.2.0" />
<engine name="windows" spec="~4.4.2" />
<plugin name="cordova-plugin-device" spec="^1.1.6" />
<plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" />
<plugin name="cordova-plugin-statusbar" spec="~2.2.3" />
<plugin name="cordova-plugin-whitelist" spec="1.2.2" />
</widget>
Cordova.js 加载得很好,但我无法让插件在浏览器之外加载。
任何方向都会非常赞赏!
编辑 我找到了一些与 TACO 工作原理相关的信息,我相信我可能处于类似于 this.
的情况您是否尝试通过 cordova plugin add <plugin name>
删除插件并重新添加它们?
什么是 cordova plugin list
输出?
cordova build android -XLint:all
的输出是什么?
检查您是否已将插件导入相应的 html 文件
您的配置似乎缺少一个重要的插件:
<plugin name="cordova-plugin-splashscreen" spec="^3.2.2" />
我的配置是3.2.2,你可以试试最新的4.0.3版本
您还可以检查 plaftorms/android/platform_www/plugins 中是否所有插件都可用:
请问post环境信息运行:
ionic info
ionic serve 会报错吗? 这可能是兼容性问题或权限问题。您还可以确认平台文件夹中不存在未找到的文件吗? 转到平台>android>platform_www>插件 在最坏的情况下,我建议您复制项目文件夹作为备份,转到项目目录删除 node_modules 文件夹, 运行:
npm install
这将更新库。
尝试在 Platforms 下的配置文件中将 Cordova CLI 更改为某个较低版本。
当 Cordova 生成插件时,它会在根目录 plugins
上创建一个文件夹。我们使用我们自己的 Plugins
文件夹来保存一些第 3 方 JS 动画插件。由于 Windows 不区分大小写的性质。浏览器中没有错误 运行。
当部署到 Android 时,Windows 将构建文件,检查 plugins
并匹配 Plugins
并将它们移动到那里。这就是提取的 apk 文件显示正确的原因。当 android 查找文件时,它与 Plugins
不匹配,根本找不到我的插件。
长话短说,不要创建大小写不同于 plugins
的文件夹来存放外部插件。