2016-09-30 40 views
2

我正在使用Mac OS來開發Android應用。我無法生成apk文件。無法加載Android應用徽標

錯誤:

Error:(14) Error: Unexpected resource reference type; expected value of type @string/ [ReferenceType]

我的XML文檔中的代碼:

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

爲什麼會產生這個錯誤嗎?

回答

4

生成該錯誤,因爲你的XML項目是一個字符串

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

,如果你想給它加載的應用程序標識(顯示在此圖像您的引用是一個資源/圖像

應用程序的抽屜) 搜索這個

android:icon="@mipmap/ic_launcher" 

在您的Android清單和替換您的圖像ic_launcher

+0

什麼可以放呢? – Melissa

+0

你想在哪裏顯示圖像? – Malik

+0

其應用程序徽標。 – Melissa

2

在字符串標籤內,您不能放置資源ID。 @mipmap/ic_lau_spt是一個圖像資源ID。

+0

可以使用什麼資源ID? – Melissa

1

在AndroidManifest.xml中

你定義在裏面的應用程序標記您的manifest.xml文件的應用程序圖標

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

是的。我已經定義了這一點。 – Melissa

+0

只需從你的strings.xml文件中刪除「 @ mipmap/ic_lau_spt」,你的項目就可以編譯並運行。 –

1

<manifest 

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

</manifest>