Android編譯時出現Process 'command 'build-tools\27.0.3\aapt.exe'' finished with non-zero exit value 1報錯

轉發如下:

https://blog.csdn.net/willba/article/details/83512363
昨天在開發一個項目時,在Android Studio中編譯時,gradle編譯之後出現瞭如下錯誤:

1Error:Execution failed for task ':samples-simplevideowidget:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\Android\SDK\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1

 

我按照以上方案一一檢查,還是未能解決,於是只能自己動手排查原因了!

1.定位錯誤點

在項目root路徑,實際上是控制檯Terminal下也可以輸入命令,命令行輸入:

gradlew processDebugResources --debug

然後項目開始編譯,屏幕上輸出大量編譯Log信息,從Log中找到了輸出的出錯信息:

1org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
2,org.gradle.process.internal.DefaultExecHandle] Process ‘command ‘E:\Android\SDK\build-tools\23.0.1\aapt.exe’’ finished with exit value 1 (state: FAILED)
3,org.gradle.api.Project] Unknown source file : ERROR: In ListItemLinearLayout, unable to find attribute singleLine
4,org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ‘:samples-simplevideowidget:processDebugResources’
5,E] [class org.gradle.TaskExecutionLogger] :samples-simplevideowidget:processDebugResources FAILED
 

從上述Log信息,我們可知出錯點是ERROR: In ListItemLinearLayout, unable to find attribute singleLine,那麼肯定是attrs文件的ListItemLinearLayoutstyleable出錯了。
2. 錯誤原因

經過上述分析,我們進入attrs.xml文件,找到ListItemLinearLayout,如下所示:
1,
2,
3,

可以看出singleLine沒有對應的format屬性,確定singleLine沒有在代碼中使用之後,將此屬性刪掉。

方法2

“Process 'command 'D:\SDK\build-tools\27.0.3\aapt.exe'' finished with non-zero exit value 1”

在網上都是在說是視圖出現問題了,但是說真的,如果去一個個檢查XML視圖真的是一件很神奇的事情。 

採取build的方式,之後一些詳細信息就會在Run裏面。會直接定位到你的XML的行數和字符數。

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