關於android Project運行中出錯Error executing aapt: Return code -1073741819

一個android HelloWorld工程在運行的過程中出現Error executing aapt: Return code -1073741819錯誤

出現錯誤後我重新新建一個工程 ,照樣還是不行,運行後照樣出現此類錯誤,後來意識到是不是我不該修改掉String.xml中的內容導致的錯誤

當初String.xml中自帶有下列標籤:

 <string name="app_name">Core</string>
   <string name="action_settings">Settings</string>
   <string name="hello_world">Hello world!</string>

被我修改後只有:

 <string name="app_name">Core</string>

。。。以及自己的幾百條string項。我修改String.xml中的內容保存時就會報錯。後臺打印的錯誤信息中顯示aapt相關錯誤。

此時在R中也找不到自動生成的我自己添加的標籤元素的相關類。

我又重新把後面兩句

 <string name="action_settings">Settings</string>
   <string name="hello_world">Hello world!</string>

放進來。再修改保存不會出現任何錯誤。在資源文件中增加的標籤元素也在R中自動生成了相應的類。

可以刪掉

   <string name="hello_world">Hello world!</string>

保留

 <string name="action_settings">Settings</string>

此後程序運行正常。

然後查找 <string name="action_settings">Settings</string>

的使用位置,發現在menu/main.xml裏面

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/action_settings"/>
</menu>

aapt是專門用來對付資源的,如果它報錯肯定是資源問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章