Android 常見錯誤以及解決方法
阿新 • • 發佈:2019-01-01
01、
解決方案:
Gradle的一個Bug,解決辦法是,刪除專案根目錄的.gradle資料夾,然後Clean ,Rebulid。
02、git 提交程式碼無法提交問題
Unable to create 'D:/work/******/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.
解決方案:找到相應位置的 index.lock 刪除即可
03、
java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.EditText
型別轉換異常,在這裡是TextView轉換成EditText,粗心導致崩潰。
解決方案:型別替換就好了
04、see the compiler error output for details
Error:Execution failed for task ':xxxx:compileStDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details.
這個花了比較多的時間來排查問題,在網路上也找了幾種方式嘗試了一下都沒有解決,在這裡總結一下自己解決的方式。
錯誤原因:
@Autowired(name = ParamKeys.ACTIVITY_XXX)
private XxxBean mXxxBean;
通過ARouter 接收引數時,多了一個 private 屬性,從而出現這種錯誤。
問題解決:
去掉 private 屬性,編譯正常。
注意:這類問題出現的原因,主要是自己的編碼的問題,應該仔細檢查自己出現問題的程式碼,看是否有比較特殊的。另外studio 右下角有一個 Gradle Console ,在這裡可以看看具體哪裡出現問題,會給你具體位置。如下:
錯誤: ARouter::Compiler An exception is encountered,
[The inject fields CAN NOT BE 'private'!!! please check field [mXxxxBean] in class [xxx.xxxx.xxxxxActivity]]