diff --git a/tool/check_apk.ps1 b/tool/check_apk.ps1 index 5aae51a..7def38d 100644 --- a/tool/check_apk.ps1 +++ b/tool/check_apk.ps1 @@ -3,11 +3,16 @@ # - 원인: android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java (git 밖, 생성 파일) 를 지운 뒤 # flutter build apk --no-pub 로 빌드하면 다시 만들어지지 않는다. 지웠으면 --no-pub 없이 빌드하거나 먼저 flutter pub get. # - (195) third_party 의 네이티브 실행 파일: android\app\third_party_libs.txt 의 것이 모두 들어 있고, 목록에 없는 third_party 파일은 없는지. -# 사용: powershell -ExecutionPolicy Bypass -File tool\check_apk.ps1 -Apk build\app\outputs\flutter-apk\app-release.apk +# - 시험판 번호 (관리자 지시 10/12): 시험판의 versionCode 가 정식 판 (git 태그 v년.월.일_번호) 과 같으면 실패. +# 918 이 --build-number 없이 빌드되어 정식 판 v2026.10.10_001 (261010001) 과 똑같이 보였다 - 사용자 기기에 깔리면 정식 판으로 보이고 +# 새 버전 확인도 "최신과 같음" 이 된다. 시험판은 flutter build apk --build-number 9xx 로 빌드한다. 정식 판 APK 는 -Release. +# 사용: powershell -ExecutionPolicy Bypass -File tool\check_apk.ps1 -Apk build\app\outputs\flutter-apk\app-release.apk [-Release] param( [Parameter(Mandatory = $true)][string]$Apk, # 목록 파일 (기본: 이 스크립트가 있는 앱 폴더의 android\app\third_party_libs.txt) - [string]$Libs = '' + [string]$Libs = '', + # 정식 판 APK (태그와 같은 번호가 맞음) - 시험판 번호 검사를 하지 않는다 + [switch]$Release ) $ErrorActionPreference = 'Stop' Add-Type -AssemblyName System.IO.Compression.FileSystem @@ -54,6 +59,20 @@ try { $zip.Dispose() } $bad = @() +# 시험판 번호: aapt2 로 versionCode · versionName 을 읽어 정식 판 태그의 번호와 견준다 (build.gradle.kts 와 같은 셈: 년%100 · 월 · 일 · 번호) +$aapt = Get-ChildItem (Join-Path $app '..\tools\android-sdk\build-tools') -Recurse -Filter aapt2.exe -ErrorAction SilentlyContinue | Select-Object -Last 1 +if (-not $aapt -and $env:ANDROID_HOME) { $aapt = Get-ChildItem (Join-Path $env:ANDROID_HOME 'build-tools') -Recurse -Filter aapt2.exe -ErrorAction SilentlyContinue | Select-Object -Last 1 } +if (-not $aapt) { throw 'aapt2.exe 를 찾지 못했습니다 (tools\android-sdk\build-tools 또는 ANDROID_HOME)' } +$badging = (& $aapt.FullName dump badging $Apk 2>$null | Select-Object -First 1) +if ($badging -notmatch "versionCode='(\d+)' versionName='([^']*)'") { throw "versionCode 를 읽지 못했습니다: $badging" } +$code = [long]$Matches[1]; $vname = $Matches[2] +$tags = @(git -C $app tag --list 'v*' 2>$null) +$same = @(foreach ($t in $tags) { + if ($t -match '^v(\d+)\.(\d+)\.(\d+)_(\d+)$' -and ([long]$Matches[1] % 100) * 10000000 + [long]$Matches[2] * 100000 + [long]$Matches[3] * 1000 + [long]$Matches[4] -eq $code) { $t } + }) +if (-not $Release -and $same) { + $bad += "시험판인데 versionCode $code ($vname) 가 정식 판 $($same -join ', ') 과 같음 - flutter build apk --build-number 9xx 로 다시 빌드 (정식 판이면 -Release)" +} foreach ($n in $listed) { if ($libsIn -notcontains $n) { $bad += "목록에 있는데 APK 에 없음: $n" } } foreach ($n in ($tp | Select-Object -Unique)) { if ($listed -notcontains $n -and $libsIn -contains $n) { $bad += "목록에 없는데 APK 에 들어감: $n" } } if ($bad) { @@ -64,4 +83,4 @@ if (-not $found) { Write-Host "실패: GeneratedPluginRegistrant 가 dex 에 없습니다 (켜자마자 꺼지는 APK). flutter pub get 뒤 --no-pub 없이 다시 빌드하세요." -ForegroundColor Red exit 1 } -Write-Host "통과: GeneratedPluginRegistrant 있음 ($found) · third_party 실행 파일 $($listed.Count)개 목록과 같음" +Write-Host "통과: GeneratedPluginRegistrant 있음 ($found) · third_party 실행 파일 $($listed.Count)개 목록과 같음 · versionCode $code ($vname)$(if ($Release) { ' (정식 판)' } else { ' (시험판 - 정식 판 번호와 다름)' })"