天天看點

android遇到的難題,Android開發遇到的三個問題

您的位置:首頁 - 教程 - IT技術 - 正文

Android開發遇到的三個問題

總結我在安卓開發過程中遇到的問題,開發工具為Android Studio 編譯工具為gradle

一.

Execution failed for task ':mergeDebugResources'

錯誤2:Execution failed for task ':mergeDebugResources'.

> Error: Failed to run command:

D:\soft_dev\android-sdk-windows\android-sdk-windows\build-tools\19.1.0\a

apt.exe s -i E:\Aworkspace\NewWorkspace\VipOneToOneGradleTest\res\drawable-xhdpi

\white.png -o E:\Aworkspace\NewWorkspace\VipOneToOneGradleTest\build\intermediat

es\res\debug\drawable-xhdpi-v4\white.png

Error Code:

42

Output:

libpng error: Not a PNG file

解決:這時候是不是感覺很迷茫,出錯了對吧,下面就告訴你是怎麼回事,怎麼出錯的。

錯誤很簡單卻也很難發覺,原因就是在這張圖檔上,為什麼是圖檔上呢,剛開始的時候你的圖檔是不是.jpg格式的,然而你把字尾名改成了.png的以為就可以了是吧,其實不是這樣,你隻是把格式改成了.png,其實它還是.jpg格式的。要将圖檔真正轉換成.png格式的才行。随便找個圖檔轉換工具就可以解決。

注意:在存放圖檔時千萬不要将格式為.jpg的圖檔改成.png格式,千萬不要偷懶,一定要将格式轉換成PNG格式的圖檔,否則編譯将不通過。切記!!!!

二.

Missing one of the key attributes 'action#name,category#name' on element

intent-filter at AndroidManifest.xml:342:13

Output:

res\drawable-xhdpi-v4\white.png:0: error: Resource entry white is alread

y defined.

res\drawable-xhdpi-v4\white.jpg:0: Originally defined here.

ce\NewWorkspace\Vi

非法字元: \65279

解決:

由于java檔案是已utf-8-bom的形式儲存的,至于為何導緻了這種情況,無需考究,通過editplus打開檔案就可以看到。然後另存為utf-8形式就可以了。再将修改了編碼的檔案替換項目中報錯的檔案,錯誤就解決了

三.

FAILURE: Build failed with an exception.

* What went wrong:Execution failed for task ':lint'.

> Lint found errors in the project; aborting build.

Fix the issues identified by lint, or add the following to your build script to proceed with errors:

android {

lintOptions {

abortOnError false

}

}

解決:這種錯誤根據英文提示直接解決就可以了

評論: