PhoneGap Build:图标和初始屏幕无法正确显示

时间:2015-05-27 10:27:48

标签: android ios cordova phonegap-build

我遇到的问题是,当我使用Phonegap Build构建应用程序时,未正确包含android和ios图标。

config.xml部分如下:

<icon src="www/res/icon/icon.png" />
<splash src="www/res/screen/splash.jpg" />

<platform name="android">
    <icon src="www/res/icon/android/icon-ldpi.png" density="ldpi" />
    <icon src="www/res/icon/android/icon-mdpi.png" density="mdpi" />
    <icon src="www/res/icon/android/icon-hdpi.png" density="hdpi" />
    <icon src="www/res/icon/android/icon-xhdpi.png" density="xhdpi" />

    <splash gap:qualifier="port-hdpi" src="www/res/screen/android/screen-hdpi-port.png" width="480" height="800" />
    <splash gap:qualifier="port-xhdpi" src="www/res/screen/android/screen-xhdpi-port.png" width="640" height="960" />
    <splash gap:qualifier="land-hdpi" src="www/res/screen/android/screen-hdpi-land.jpg" width="800" height="480" />
    <splash gap:qualifier="land-xhdpi" src="www/res/screen/android/screen-xhdpi-land.jpg" width="960" height="640" />
</platform>

<platform name="ios">
    <!-- iOS 7.0+ -->
    <!-- iPhone / iPod Touch  -->
    <icon src="www/res/icon/ios/icon-60.png" width="60" height="60" />
    <icon src="www/res/icon/ios/icon-60@2x.png" width="120" height="120" />
    <icon src="www/res/icon/ios/icon-60@3x.png" width="180" height="180" />
    <!-- iPad -->
    <icon src="www/res/icon/ios/icon-76.png" width="76" height="76" />
    <icon src="www/res/icon/ios/icon-76@2x.png" width="152" height="152" />
    <!-- iOS 6.1 -->
    <!-- Spotlight Icon -->
    <icon src="www/res/icon/ios/icon-40.png" width="40" height="40" />
    <icon src="www/res/icon/ios/icon-40@2x.png" width="80" height="80" />
    <!-- iPhone / iPod Touch -->
    <icon src="www/res/icon/ios/icon.png" width="57" height="57" />
    <icon src="www/res/icon/ios/icon@2x.png" width="114" height="114" />
    <!-- iPad -->
    <icon src="www/res/icon/ios/icon-72.png" width="72" height="72" />
    <icon src="www/res/icon/ios/icon-72@2x.png" width="144" height="144" />
    <!-- iPhone Spotlight and Settings Icon -->
    <icon src="www/res/icon/ios/icon-small.png" width="29" height="29" />
    <icon src="www/res/icon/ios/icon-small@2x.png" width="58" height="58" />
    <!-- iPad Spotlight and Settings Icon -->
    <icon src="www/res/icon/ios/icon-50.png" width="50" height="50" />
    <icon src="www/res/icon/ios/icon-50@2x.png" width="100" height="100" />

    <!-- Splash sreens -->
    <splash src="www/res/screen/ios/screen-iphone-portrait-2x.png" height="960" width="640" />
    <splash src="www/res/screen/ios/screen-iphone-landscape-2x.jpg" height="640" width="960" />
    <splash src="www/res/screen/ios/screen-iphone-portrait-568h-2x.png" height="1136" width="640" />
    <splash src="www/res/screen/ios/screen-iphone-landscape-568h-2x.jpg" height="640" width="1136" />
    <splash src="www/res/screen/ios/screen-ipad-portrait.png" height="1024" width="768" />
    <splash src="www/res/screen/ios/screen-ipad-landscape.jpg" height="768" width="1024" />
</platform>

<platform name="wp8">
    <icon src="www/res/icon/wp/ApplicationIcon.png" width="99" height="99" />
    <!-- tile image -->
    <icon src="www/res/icon/wp/Background.png" width="159" height="159" />  
    <splash src="www/res/screen/wp/SplashScreenImage.png" width="768" height="1280"/>
</platform>

文件确实存在于所述文件夹中,它们甚至分别显示在assets/www/respayload/myApp.app/www/res中的apk和ipa内。但是,phonegap构建不会将它们复制到res/drawable-*payload/myApp.app。相反,它使用默认图标和启动画面(Android中的Cordova bot和iOS中的透明图像)。

WP8版本在本地完成,就像一个魅力。 我已经删除了Phonegap Build中的应用并重新创建了它,但没有更改图标,现在只有应用ID高了一点。

我是否必须将图标放在特殊位置,或者config.xml中是否存在问题?

更新:我刚看了iOS构建的调试输出。有些PNG会被复制,但ipa仍然包含Payload\MyApp.app中的透明图标。示例复制日志:

CopyPNGFile build/MyApp.app/icon-76.png MyApp/Resources/icons/icon-76.png
    cd /project
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng -compress /project/MyApp/Resources/icons/icon-76.png /project/build/MyApp.app/icon-76.png

对于android来说同样如此:

[crunch] Processing image to cache: /project/res/drawable-hdpi/icon.png => /project/bin/res/drawable-hdpi/icon.png
[crunch]   (processed image to cache entry /project/bin/res/drawable-hdpi/icon.png: 67% size of source)

好吧,我确实在config.xml中定义了其他目录/文件!

3 个答案:

答案 0 :(得分:1)

我也遇到过SplashScreen的问题,请参阅下一个答案:https://stackoverflow.com/a/26427769/1800695

config.xml旁边添加:

<preference name="SplashScreen" value="screen"/>

这些是config.xml中用于图标和启动画面的条目(仅限Android):

<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<platform name="android">
    <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
    <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
    <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
    <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
    <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
    <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
    <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
    <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
    <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
    <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
    <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
    <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
</platform>
<icon src="resources/android/icon/drawable-xhdpi-icon.png" />

此NPM包也可能有任何意义:https://www.npmjs.com/package/cordova-media-generator

答案 1 :(得分:0)

问题中显示的语法是本地Cordova的语法。

似乎Phonegap Build服务不使用相同的语法。如果您使用gap:platform属性贴近the Phonegap Build docs,而不是将图标嵌套到platform标记中,Phonegap Build可以正常工作。

答案 2 :(得分:0)

尝试跟上文档..密度在 end.exmpl 中声明:

<platform name="android">
        <splash src="res/screen/android/screen-hdpi-landscape.png" density="land-hdpi" />
        <splash src="res/screen/android/screen-ldpi-landscape.png" density="land-ldpi" />
        <splash src="res/screen/android/screen-mdpi-landscape.png" density="land-mdpi" />
        <splash src="res/screen/android/screen-xhdpi-landscape.png" density="land-xhdpi" />

        <splash src="res/screen/android/screen-hdpi-portrait.png" density="port-hdpi" />
        <splash src="res/screen/android/screen-ldpi-portrait.png" density="port-ldpi" />
        <splash src="res/screen/android/screen-mdpi-portrait.png" density="port-mdpi" />
        <splash src="res/screen/android/screen-xhdpi-portrait.png" density="port-xhdpi" />
</platform>

这是我工作的config.xml的一部分,

也是src souldnt&#34; www /.../..."由于构建过程中的错误,只有根项目文件夹。如何在build / android / res / multipleFolders - &gt;中查看构建是否应该通过的方式应该使用screenplash img填充的文件夹,这些文件夹不会由您手动添加。