看見筆記是一個四年前的專案,SDK 版本 31、Kotlin 版本 1.6.10,現在的 SDK 版本 36、Kotlin 版本 2.1.0
對於 Android 的世界,想要把一個舊專案直接更新的最新版,是一件很難的事情,就好比要把一台閒置在路邊四年的汽車鑰匙插入就期待能正常發動一樣
但有機會直接靠 Vibe Coding 無腦把舊專案升級到最新嗎,來實驗看看吧
我先建立一個新資料夾,裡面有兩個專案
你是Android資深工程師,你很熟練的升級Android專案SDK版本,請你參考KotlinApplication專案的內容,把SeeNote專案的SDK版本和Gradle對齊KotlinApplication
● 我來幫你升級SeeNote專案的SDK版本和Gradle,使其與KotlinApplication專案對齊。讓我先檢查兩個專案的配置。
● 現在我已經檢查了兩個專案的配置,以下是對比結果:
KotlinApplication專案配置:
- Gradle版本:8.13
- compileSdk:36
- targetSdk:36
- minSdk:24
- Java版本:11
- Kotlin使用libs.versions.toml管理
SeeNote專案目前配置:
- Gradle版本:7.2
- AGP版本:7.1.3
- compileSdk:31
- targetSdk:31
- minSdk:23
- Java版本:1.8
- Kotlin版本:1.6.10
AI 第一次修改後,執行 Sync Gradle 後正常執行,本來以為 AI 居然那麼猛,結果他沒有把 Gradle 換成最新的 Kotlin DSL,所以罵一罵後又要他繼續
你的Gradle沒有換成Kotlin DSL
● 你說得對!我需要將SeeNote專案的Gradle配置從Groovy DSL轉換為Kotlin DSL,以與KotlinApplication專案保持一致。
中間省略
● ✅ SeeNote專案已成功轉換為Kotlin DSL!
再次執行 Sync Gradle 後失敗,真是鬆了一口氣,不然 AI 太厲害我怕失業
出現錯誤,修正他
Build file 'D:\Android Project\ItHome\SeeNote\build.gradle.kts' line: 2
Plugin [id: 'com.android.application', version: '8.7.3', apply: false] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.7.3')
Searched in the following repositories:
Gradle Central Plugin Repository
● 我需要修正這個錯誤。問題是libs.versions.toml中的plugin名稱不正確,以及需要添加必要的repositories。
還是出現錯誤,修正他
Build file 'D:\Android Project\ItHome\SeeNote\build.gradle.kts' line: 16
Plugin [id: 'com.android.application', version: '8.7.2', apply: false] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.7.2')
Searched in the following repositories:
Gradle Central Plugin Repository
● 問題在於AGP 8.7.2版本不存在。讓我檢查正確的AGP版本並修正。
● AGP 8.7.x版本不存在。讓我使用正確的AGP版本,對應Gradle 8.13應該使用AGP 8.7或8.6版本:
這次我用了兩套,分別是 Gemini CLI 和 Claude Code,問到最後都卡在找不到正確的 AGP 版本號,看來用 Vibe Coding 一次到位失敗了,明天再嘗試人工修正版本號不存在的問題