草庐IT

android - Phonegap/ionic 应用启动画面未显示

coder 2023-09-26 原文

我一直在反复尝试为我的 Ionic 应用程序添加启动画面。我们正在使用 Phonegap 3.7.0 将其部署到 ios 和 android 设备,但似乎没有任何效果。奇怪的是,当我在模拟器中运行该应用程序时,会显示启动画面(例如:ionic emulate android)

使用此配置,图标可以正常工作,但启动画面无法正常工作。它显示一个空白屏幕,甚至没有 cordova 默认启动画面。

我的配置文件:

<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="ShowSplashScreenSpinner" value="true"/>
<preference name="SplashScreenDelay" value="5000"/>
<preference name="SplashScreen" value="screen"/>

<gap:plugin name="org.apache.cordova.device"/>
<gap:plugin name="org.apache.cordova.network-information"/>
<gap:plugin name="org.apache.cordova.inappbrowser"/>
<gap:plugin name="uk.co.whiteoctober.cordova.appversion" version="0.1.4"/>
<gap:plugin name="org.apache.cordova.statusbar" version="0.1.4" source="pgb"/>
<gap:plugin name="com.ionic.keyboard" version="1.0.3" source="pgb"/>
<gap:plugin name="nl.x-services.plugins.socialsharing" version="4.3.8" source="pgb"/>
<gap:plugin name="fi.avaus.cordova.geolocation"/>
<gap:plugin name="org.apache.cordova.splashscreen" version="0.3.4"/>
<platform name="ios">
  <icon src="resources/ios/icon/icon.png" gap:platform="ios" width="57" height="57"/>
  <icon src="resources/ios/icon/icon@2x.png" gap:platform="ios" width="114" height="114"/>
  <icon src="resources/ios/icon/icon-40.png" gap:platform="ios" width="40" height="40"/>
  <icon src="resources/ios/icon/icon-40@2x.png" gap:platform="ios" width="80" height="80"/>
  <icon src="resources/ios/icon/icon-50.png" gap:platform="ios" width="50" height="50"/>
  <icon src="resources/ios/icon/icon-50@2x.png" gap:platform="ios" width="100" height="100"/>
  <icon src="resources/ios/icon/icon-60.png" gap:platform="ios" width="60" height="60"/>
  <icon src="resources/ios/icon/icon-60@2x.png" gap:platform="ios" width="120" height="120"/>
  <icon src="resources/ios/icon/icon-60@3x.png" gap:platform="ios" width="180" height="180"/>
  <icon src="resources/ios/icon/icon-72.png" gap:platform="ios" width="72" height="72"/>
  <icon src="resources/ios/icon/icon-72@2x.png" gap:platform="ios" width="144" height="144"/>
  <icon src="resources/ios/icon/icon-76.png" gap:platform="ios" width="76" height="76"/>
  <icon src="resources/ios/icon/icon-76@2x.png" gap:platform="ios" width="152" height="152"/>
  <icon src="resources/ios/icon/icon-small.png" gap:platform="ios" width="29" height="29"/>
  <icon src="resources/ios/icon/icon-small@2x.png" gap:platform="ios" width="58" height="58"/>
  <icon src="resources/ios/icon/icon-small@3x.png" gap:platform="ios" width="87" height="87"/>
  <gap:splash src="resources/ios/splash/Default-568h@2x~iphone.png" gap:platform="ios" width="640" height="1136"/>
  <gap:splash src="resources/ios/splash/Default-667h.png" gap:platform="ios" width="750" height="1334"/>
  <gap:splash src="resources/ios/splash/Default-736h.png" gap:platform="ios" width="1242" height="2208"/>
  <gap:splash src="resources/ios/splash/Default-Landscape-736h.png" gap:platform="ios" width="2208" height="1242"/>
  <gap:splash src="resources/ios/splash/Default-Landscape@2x~ipad.png" gap:platform="ios" width="2048" height="1536"/>
  <gap:splash src="resources/ios/splash/Default-Landscape~ipad.png" gap:platform="ios" width="1024" height="768"/>
  <gap:splash src="resources/ios/splash/Default-Portrait@2x~ipad.png" gap:platform="ios" width="1536" height="2048"/>
  <gap:splash src="resources/ios/splash/Default-Portrait~ipad.png" gap:platform="ios" width="768" height="1024"/>
  <gap:splash src="resources/ios/splash/Default@2x~iphone.png" gap:platform="ios" width="640" height="960"/>
  <gap:splash src="resources/ios/splash/Default~iphone.png" gap:platform="ios" width="320" height="480"/>
</platform>
<platform name="android">
  <icon src="resources/android/icon/drawable-ldpi-icon.png" gap:platform="android" density="ldpi"/>
  <icon src="resources/android/icon/drawable-mdpi-icon.png" gap:platform="android" density="mdpi"/>
  <icon src="resources/android/icon/drawable-hdpi-icon.png" gap:platform="android" density="hdpi"/>
  <icon src="resources/android/icon/drawable-xhdpi-icon.png" gap:platform="android" density="xhdpi"/>
  <icon src="resources/android/icon/drawable-xxhdpi-icon.png" gap:platform="android" density="xxhdpi"/>
  <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" gap:platform="android" density="xxxhdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-ldpi-screen.png" gap:platform="android" density="land-ldpi"/>
  <gap:splash src="resources/android/splash/drawable-land-mdpi-screen.png" gap:platform="android" density="land-mdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-hdpi-screen.png" gap:platform="android" density="land-hdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-xhdpi-screen.png" gap:platform="android" density="land-xhdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" gap:platform="android" density="land-xxhdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" gap:platform="android" density="land-xxxhdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-ldpi-screen.png" gap:platform="android" density="port-ldpi"/>
  <gap:splash src="resources/android/splash/drawable-port-mdpi-screen.png" gap:platform="android" density="port-mdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-hdpi-screen.png" gap:platform="android" density="port-hdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-xhdpi-screen.png" gap:platform="android" density="port-xhdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" gap:platform="android" density="port-xxhdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" gap:platform="android" density="port-xxxhdpi"/>
</platform>
<icon src="icon.png" />
<gap:splash src="splash.png" />

正如 phonegap 文档所述:您的初始屏幕应保存为 png 文件。 它们是什么,我添加了平台标签“gap:platform”

并且默认启动画面必须命名为 splash.png 并且必须位于应用程序文件夹的根目录中。

这是我的项目树

root
- bower_components
- hooks
- node_modules
- platforms
- plugins

- resources
-- android
--- icon
--- splash
  drawable-land-hdpi-screen.png
  drawable-land-ldpi-screen.png
  drawable-land-mdpi-screen.png
  etc...
-- ios
--- icon
--- splash
  Default-568h@2x~iphone.png
  Default-667h.png
  Default-736h.png
  etc...
-- icon.png
-- splash.png
- scss
- www

bower.json
config.xml
gulpfile.js
icon.png
ionic.project
package.json
splash.png

http://i59.tinypic.com/9bhbw5.jpg

希望有人能给我一个解决方案 提前谢谢你

编辑:

我已经从运行闪屏的模拟器中反编译了 APK 文件,并从 phonegap build 中反编译了 APK 文件。似乎 phonegap 没有复制启动画面文件夹,也没有使用正确的 config.xml 文件。

来自 phonegap 构建的 config.xml

    <?xml version="1.0" encoding="utf-8"?>
<widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets">
    <name> Hello Cordova
</name>
    <description> A sample Apache Cordova application that responds to the deviceready
        event. </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io"> Apache Cordova Team </author>
    <access origin="http://*/*" />
    <access origin="https://*/*" />
    <access launch-external="yes" origin="tel:*" />
    <access launch-external="yes" origin="geo:*" />
    <access launch-external="yes" origin="mailto:*" />
    <access launch-external="yes" origin="sms:*" />
    <access launch-external="yes" origin="market:*" />
    <preference name="loglevel" value="DEBUG" />
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="android-minSdkVersion" value="16" />
    <preference name="AutoHideSplashScreen" value="false" />
    <preference name="ShowSplashScreenSpinner" value="true" />
    <preference name="SplashScreenDelay" value="5000" />
    <content src="index.html" />
    <feature name="StatusBar">
        <param name="android-package" onload="true" value="org.apache.cordova.statusbar.StatusBar" />
    </feature>
    <feature name="AppVersion">
        <param name="android-package" value="uk.co.whiteoctober.cordova.AppVersion" />
    </feature>
    <feature name="Keyboard">
        <param name="android-package" value="com.ionic.keyboard.IonicKeyboard" />
        <param name="onload" value="true" />
    </feature>
    <feature name="InAppBrowser">
        <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
    </feature>
    <feature name="NetworkStatus">
        <param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
    </feature>
    <feature name="Device">
        <param name="android-package" value="org.apache.cordova.device.Device" />
    </feature>
    <feature name="SocialSharing">
        <param name="android-package" value="nl.xservices.plugins.SocialSharing" />
    </feature>
    <feature name="SplashScreen">
        <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
    </feature>
    <feature name="GeolocationAvailabilityChecker">
        <param name="android-package" value="org.apache.cordova.geolocation.GeolocationAvailabilityChecker" />
    </feature>
</widget>

看起来 phonegap 构建配置不正确

最佳答案

如果有人仍然遇到此问题,请在运行 ionic resources 命令后确保将以下内容添加到 config.xml 中:

  <preference name="ShowSplashScreen" value="true" />
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="3000"/>
  <preference name="AutoHideSplashScreen" value="true" />
  <preference name="SplashShowOnlyFirstTime" value="false" />
  <preference name="FadeSplashScreen" value="false"/>
  <feature name="SplashScreen">
    <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
  </feature>

然后运行:

ionic build android
ionic run android

完成。

关于android - Phonegap/ionic 应用启动画面未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31557887/

有关android - Phonegap/ionic 应用启动画面未显示的更多相关文章

  1. ruby - 将差异补丁应用于字符串/文件 - 2

    对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl

  2. ruby-on-rails - Rails 编辑表单不显示嵌套项 - 2

    我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib

  3. ruby - 解析 RDFa、微数据等的最佳方式是什么,使用统一的模式/词汇(例如 schema.org)存储和显示信息 - 2

    我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i

  4. ruby-on-rails - Rails 应用程序之间的通信 - 2

    我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此

  5. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  6. ruby-on-rails - Rails 应用程序中的 Rails : How are you using application_controller. rb 是新手吗? - 2

    刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr

  7. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  8. ruby-on-rails - 启动 Rails 服务器时 ImageMagick 的警告 - 2

    最近,当我启动我的Rails服务器时,我收到了一长串警告。虽然它不影响我的应用程序,但我想知道如何解决这些警告。我的估计是imagemagick以某种方式被调用了两次?当我在警告前后检查我的git日志时。我想知道如何解决这个问题。-bcrypt-ruby(3.1.2)-better_errors(1.0.1)+bcrypt(3.1.7)+bcrypt-ruby(3.1.5)-bcrypt(>=3.1.3)+better_errors(1.1.0)bcrypt和imagemagick有关系吗?/Users/rbchris/.rbenv/versions/2.0.0-p247/lib/ru

  9. ruby-on-rails - 如何在我的 Rails 应用程序 View 中打印 ruby​​ 变量的内容? - 2

    我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby​​中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R

  10. ruby-on-rails - link_to 不显示任何 rails - 2

    我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article

随机推荐