這裡整理 Android Studio 開發 Android APP 過程時,常遇到的問題及解決方法;

1. Android Studio 安裝並載入設定後,啟動舊有 code 專案,在首次Gradle build 時總是卡住,

自行執行 compile 時會出現以下錯誤:

Gradle error : Write access is allowed from event dispatch thread only in android studio

解決方法:

採用下列作法即可恢復正常,並將整個 android studio 關閉後再重新啟動,自動載入正確的 jre 即可恢復;

File -> Project Structure -> SDK Location), 勾選 'Use embedded JDK' checkbox and set jdk location to 'path to android studio'\Android Studio\jre

2.  Error message: Session 'app': Error Installing APK

解決方法:

File->Settings->Build, Execution, Deplyment -> Instant Run->Disable "Enable Instant Run to hot swap code..."

3. Error:Execution failed for task ':app:mergeDebugResources'

解決方法:

應該是 resources 資料夾中有錯誤的資料、或不應該存在的檔案,本次的原因是我在 strings.xml 中宣告一個含有空白項目的陣列,刪除空白後就恢復正常了。

    <string-array name="content_array">
        <item>  </item>   //不應該加入這一項,會造成錯誤
        <item>家樂福</item>
        <item>大潤發</item>
        </string-array>
arrow
arrow

    genlee 發表在 痞客邦 留言(0) 人氣()