Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

Android 開發常見錯誤整理與排解

編輯:關於 Android 開發

Android 開發常見錯誤整理與排解

Error: Found item Attr/border_width more than one time

這個錯誤比較單純,代表屬性重複定義了。依提示搜尋找出重複處刪掉即可,要特別注意大小寫,很容易一不小心就忽略。

Error: Execution failed for task ':app:processDebugResources'

ProcessException: aapt.exe finished with non-zero exit value 1

這個錯誤通常是因为你在 style 中定義了屬性:

<style name="name">
    <item name="actionSheetBackground">@mipmap/bg</item>
</style>

卻忽略了在 declare-styleable 中宣告型別:

<declare-styleable name="ActionSheet">
    <attr name="actionSheetBackground" format="color|reference" />
</declare-styleable>

而後續的引用方式為:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.xml);
    setTheme(R.style.name);
}

資源錯誤

網路上多說是 v7 包衝突。在 23 以下版本的做法是刪掉相容包,這的確可行,但並非理想;也有人說 23 版本已修復,於是改成 23 版,然而錯誤仍在。後來才發現是因為某個 color 屬性導致的:

把帶有 color 屬性的部分刪掉或改掉就 OK 了。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved