Skip to content

Instantly share code, notes, and snippets.

@pask23
Created December 1, 2023 00:52
Show Gist options
  • Select an option

  • Save pask23/86ef14f88a90279951cad09883fd8d87 to your computer and use it in GitHub Desktop.

Select an option

Save pask23/86ef14f88a90279951cad09883fd8d87 to your computer and use it in GitHub Desktop.
androidcheckertools

Nel caso in cui venga fornita una cartella come argomento, lo script itera su tutti i file APK all'interno della cartella. Se vengono forniti singoli file APK come argomenti, verranno trattati uno per uno.

Puoi eseguire lo script in questo modo:

./check_version_code.sh path/to/your/apps

oppure

./check_version_code.sh path/to/your/app1.apk path/to/your/app2.apk

Assicurati di dare i permessi di esecuzione allo script: chmod +x check_version_code.sh

#!/bin/bash
# Imposta il percorso dell'SDK di Android
android_sdk_path=C:/Users/A472260/AppData/Local/Android/Sdk
# Verifica che sia stato fornito almeno un argomento
if [ $# -eq 0 ]; then
echo "Usage: $0 path/to/your/app(s).apk"
exit 1
fi
# Funzione per ottenere il version code di un APK
get_version_code() {
$android_sdk_path/build-tools/33.0.1/aapt dump badging "$1" | grep versionCode | sed -E 's/.*versionCode[[:digit:]]+="([[:digit:]]+)".*/\1/'
}
# Se viene fornita una cartella, itera sui file APK al suo interno
if [ -d "$1" ]; then
for apk_file in "$1"/*.apk; do
if [ -f "$apk_file" ]; then
version_code=$(get_version_code "$apk_file")
echo "APK: $apk_file, Version Code: $version_code"
fi
done
else
# Se vengono forniti singoli file APK
for apk_file in "$@"; do
if [ -f "$apk_file" ]; then
version_code=$(get_version_code "$apk_file")
echo "APK: $apk_file, Version Code: $version_code"
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment