Android的一些error及其解決方案及建議
(第一次寫部落格勿噴 謝謝)
有的小夥伴用新建的專案就沒法編譯
出現圖中錯誤
app/build.gradle
將其設定為compile ‘com.android.support:appcompat-v7:26.0.0’
更推薦升級AS
手動分割<!----------------------------------------------------------------------------------------------------------------------------------------------->
當編輯器未發現錯誤,logcat也沒有的時候build->clean progect (未必有效)
手動分割<!---------------------------------------------------------------------------------------------------------------------------------------------->
在新增圖片時:
Error:java.lang.RuntimeException: Some file crunching failed, see logs for details Error:Execution failed for task ':app:mergeDebugResources'. Error: java.lang.RuntimeException: Some file crunching failed, see logs for details
可在app/build.gradle中新增
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
手動分割<!------------------------------------------------------------------------------------------------------------------------------------>
在build檔案中,當代碼為:
implementation 'com.android.support:design:24.1.0' mplementation 'com.android.support:appcompat-v7:28.0.0'
Alt+Enter提示訊息為:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 24.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:design:24.1.0 less… (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible
他們有相容問題可改成,可將程式碼改成
implementation 'com.android.support:design:28.0.0'
手動分割<!-------------------------------------------------------------------------------------------------------------------------------------->
element relativelayout must be declared 說明.xml檔案所在的包(檔案)不對