【问题标题】:Ionic Framework: 'ionic resources' generating empty directories with no icon and splash images离子框架:“离子资源”生成没有图标和启动图像的空目录
【发布时间】:2016-06-28 10:06:44
【问题描述】:

我正在使用 ionic 框架版本 1.7.14 创建一个 android 应用程序。我正在尝试按照here 中提到的步骤生成图标和启动画面。

我在项目的根目录下创建了一个目录“resources”,并在其中添加了 2 个图像:icon.png (192x192) 和 splash.png (2208x2208)。现在当我跑步时

$ ionic resources

它在资源中生成目录“android”,其中包含子目录“icon”和“splash”。但是,没有生成图像。所有目录都是空的,并且在构建项目时出现以下错误:

Android project created with cordova-android@5.1.1
cp: no such file or directory: /myprojects/testApp/resources/android/icon/drawable-ldpi-icon.png

cp: no such file or directory: /myprojects/testApp/resources/android/icon/drawable-mdpi-icon.png

cp: no such file or directory: /myprojects/testApp/resources/android/icon/drawable-hdpi-icon.png

cp: no such file or directory: /myprojects/testApp/resources/android/icon/drawable-xhdpi-icon.png

cp: no such file or directory: /myprojects/testApp/resources/android/icon/drawable-xxhdpi-icon.png

cp: no such file or directory: /myprojects/testApp/resources/android/icon/drawable-xxxhdpi-icon.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-land-ldpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-land-mdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-land-hdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-land-xhdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-land-xxhdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-land-xxxhdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-port-ldpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-port-mdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-port-hdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-port-xhdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-port-xxhdpi-screen.png

cp: no such file or directory: /myprojects/testApp/resources/android/splash/drawable-port-xxxhdpi-screen.png

【问题讨论】:

    标签: android cordova ionic-framework ionic-cli


    【解决方案1】:

    ionic cordova resources 依赖于 ionic 服务器,可能由于网络问题或 ionic 服务器问题而失败。只需确认图标和启动文件已放入PROJECT_FOLDER/resources,然后重试。希望这会对您有所帮助,如果没有,也许您可​​以重新安装 ionic。

    【讨论】:

    • 我试过了,看来是网络状况影响ionic resources。谢谢。
    • 看起来是离子服务器的问题。几天后我再次尝试时,问题自动解决了。
    • 这里也一样。这是 ionic 方面的服务器错误,他们没有通知我他们损坏的服务器已损坏,而是给了我一个模糊的 404。
    【解决方案2】:

    据我所知,您不必创建资源文件夹。它是默认创建的:ionic start myapp [template]

    离子资源 --icon(创建图标)

    离子资源 --splash(创建启动画面)

    您必须替换资源文件夹中的默认 icon.png 和 splash.png 并确保它们具有正确的指定尺寸。

    如果这些不起作用,请尝试再次删除并添加 android 或 ios 平台。

    【讨论】:

    • 尝试删除和添加平台。这次它默认生成了资源文件夹。但是当我替换默认的 icon.png 和 splash.png 并运行“离子资源”时,它什么也没做。 resources/android/icon 和 resource/android/splash 文件夹仍然有默认的 ionic 图像
    • 我猜你的资源文件被缓存了。它是否发生在您的所有项目中。请通过创建一个空项目并在该项目上运行离子资源来验证这一点。如果它被缓存,您将不得不从平台上删除所有资源文件 .png 并尝试使用离子资源。还记得你必须运行 ionic build android 或 ionic prepare andriod
    • 1 - 离子准备 android 2 - 离子准备 ios 3 - 离子资源
    【解决方案3】:

    你说:

    我已经创建了一个目录'resource'

    那么这就是你的问题所在。这是resources 不是resource

    只需将icon.pngsplash.png 放入资源文件夹并运行ionic resources

    【讨论】:

    • 写这个问题是一个错字。我创建的目录只是“资源”
    【解决方案4】:

    我遇到了同样的问题。在我的情况下,原因是非二次飞溅图像。 (无缘无故,这个图形人用 2208x2205 让我大吃一惊)

    我将图像更改为 2205x2205 并且可以正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-25
      • 2018-05-17
      • 1970-01-01
      • 2016-10-27
      • 2016-12-26
      • 2014-06-10
      • 1970-01-01
      相关资源
      最近更新 更多