Android - AGP 8.0 之后與Greendao的兼容問題解決方案

1、首先就是要確保GreenDao的版本;

classpath 'org.greenrobot:greendao-gradle-plugin:3.3.1'

項(xiàng)目中依賴3.3.0就行了(雖然GTP認(rèn)為要使用3.3.1,但至少我目前編譯是無法通過的)

implementation 'org.greenrobot:greendao:3.3.0'

2、其次還有一個(gè)問題

':app:compileDebugKotlin' uses this output of task ':app:greendao' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

這個(gè)問題是和Kotlin-TASK編譯有關(guān)的。

GPT推薦的解決方案是

afterEvaluate {
    tasks.named('compileDebugKotlin') {
        dependsOn(tasks.named('greendao'))
    }

    // 如果還有其他變體
    tasks.named('compileReleaseKotlin') {
        dependsOn(tasks.named('greendao'))
    }
}

問題原因
在 AGP 8.0 + GreenDAO 3.3.1 組合中,Gradle 需要明確知道:

greendao 任務(wù)必須在 compileDebugKotlin 之前執(zhí)行

Kotlin 編譯依賴于 GreenDAO 生成的代碼

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容