【问题标题】:Unable to load the logo of Android app无法加载 Android 应用的 logo
【发布时间】:2017-02-08 18:55:48
【问题描述】:

我正在使用 Mac OS 开发 Android 应用。我无法生成apk文件。

错误:

错误:(14)错误:意外的资源引用类型; @string/ [ReferenceType] 类型的期望值

我在 XML 文档中的代码:

<string name="icon_name">@mipmap/ic_lau_spt</string>

为什么会产生错误?

【问题讨论】:

    标签: android macos apk


    【解决方案1】:

    产生错误是因为你的 xml 项是一个字符串

    <string name="icon_name">@mipmap/ic_lau_spt</string>
       ^                                           ^
    

    你的参考是一个资源/图像

    如果您想将其加载为应用程序徽标(在应用程序抽屉中显示此图像) 搜索这个

    android:icon="@mipmap/ic_launcher"
    

    在您的 android 清单中并用您的图像替换 ic_launcher

    【讨论】:

    • 可以放什么代替?
    • 它的应用程序徽标。
    • 只需将android:icon="@mipmap/ic_lau_spt" 放在AndroidManifest 文件中的 处即可。
    • 只需从您的 strings.xml 文件中删除“@mipmap/ic_lau_spt”。
    【解决方案2】:

    在字符串标签内不能放置资源ID。 @mipmap/ic_lau_spt 是图片资源id。

    【讨论】:

    • 可以使用什么资源id?
    【解决方案3】:

    在您的 AndroidManifest.xml 中

    您定义应用程序图标

    <application
        android:icon="@mipmap/ic_launcher">
    </application>
    

    【讨论】:

    • 只需从您的项目将编译和运行的 strings.xml 文件中删除“@mipmap/ic_lau_spt”。
    【解决方案4】:

    在您的 manifest.xml 文件中的应用程序标签中放置

    <manifest
    
      <application
            android:icon="@mipmap/ic_launcher">
      </application>
    
    </manifest>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-20
      • 1970-01-01
      相关资源
      最近更新 更多