iT邦幫忙

2025 iThome 鐵人賽

DAY 10
0

看見筆記是一個四年前的專案,SDK 版本 31、Kotlin 版本 1.6.10,現在的 SDK 版本 36、Kotlin 版本 2.1.0

對於 Android 的世界,想要把一個舊專案直接更新的最新版,是一件很難的事情,就好比要把一台閒置在路邊四年的汽車鑰匙插入就期待能正常發動一樣

但有機會直接靠 Vibe Coding 無腦把舊專案升級到最新嗎,來實驗看看吧

我先建立一個新資料夾,裡面有兩個專案

  1. 看見筆記
  2. 新建立的 Android 專案,用來給 AI 當範例

對話開始

第一次對話

  • 我的提示詞
    你是Android資深工程師,你很熟練的升級Android專案SDK版本,請你參考KotlinApplication專案的內容,把SeeNote專案的SDK版本和Gradle對齊KotlinApplication
    
  • AI 的回應
    ● 我來幫你升級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
    
  • AI 的回應
    ● 你說得對!我需要將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
    
  • AI 的回應
    ● 我需要修正這個錯誤。問題是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
    
  • AI 的回應
    ● 問題在於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 一次到位失敗了,明天再嘗試人工修正版本號不存在的問題


上一篇
114/09 - 更多 MCP 做好準備
系列文
看見筆記捲土重來,試著用 Vibe Coding 完成一款 App 吧!10
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 則留言

1
RayYuanLiu
iT邦新手 5 級 ‧ 2025-09-24 09:41:15

你的提示詞怎麼這麼像我老闆會對我說的話?

AndyAWD iT邦新手 2 級 ‧ 2025-09-24 21:58:14 檢舉

我都付錢了,肯定要當慣老闆

1
chiaominchang222
iT邦新手 5 級 ‧ 2025-09-24 19:22:45

罵了一年多哈

我要留言

立即登入留言