Skip to content

Comments

Update apktool.bat to properly handle minor decimal versions to find highest version#3913

Merged
iBotPeaches merged 1 commit intoiBotPeaches:masterfrom
mdee5test:mdee5test-patch-1
Jul 22, 2025
Merged

Update apktool.bat to properly handle minor decimal versions to find highest version#3913
iBotPeaches merged 1 commit intoiBotPeaches:masterfrom
mdee5test:mdee5test-patch-1

Conversation

@mdee5test
Copy link
Contributor

Fixed finding correct highest version in windows when minor version is more than one digit (e.g. 2.12.0), where 12 is minor version. Formerly, 2.**.0 is parsed as less than 2.*.0 due to Windows batch limitation of handling only whole integers, so a folder having multiple apktool jars, would not use the latest if the minor version is more than one digit. Fixed now.

…ding highest version

Fixed finding correct highest version in windows when minor version is more than one digit (e.g. 2.12.0). Formerly, 2.**.0 is parsed as less than 2.*.0 due to Windows batch limitation of handling only whole integers
@iBotPeaches
Copy link
Owner

I don't dev on Windows so might just have to take your word on it. Do you have any screenshots or proof of work to help ease my concern how this works?

@iBotPeaches iBotPeaches requested a review from Copilot July 20, 2025 00:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes version comparison logic in the Windows batch script to properly handle multi-digit minor versions (e.g., 2.12.0) when selecting the highest version of apktool.jar. The previous implementation incorrectly treated version strings as simple string comparisons, causing issues when minor versions exceeded single digits.

  • Replaces single-line version parsing with proper semantic version comparison
  • Implements separate tracking of major, minor, and patch version components
  • Adds proper version comparison logic that handles multi-digit version numbers correctly

set "filename=%%~nF"

rem Extract version part (apktool-X.Y.Z)
for /f "tokens=2 delims=_-" %%A in ("!filename!") do (
Copy link

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delimiter parsing assumes a specific filename format with either underscore or hyphen separators. Consider adding validation to ensure the version extraction succeeds, as malformed filenames could cause the version parsing to fail silently.

Copilot uses AI. Check for mistakes.
@mdee5test
Copy link
Contributor Author

Hi, sure!
Here's a screenshot of the previous behavior:

image

Notice the apktools in the folder, different versions. Whenever there's a new release, I download the jar to the folder containing previous versions, since apktool.bat automatically finds the latest version. The folder is in my Windows "Path" variable, so calling "apktool ..." would invoke apktool.bat, which finds the latest version of the jar in the folder, and executes it. The screenshot above is the behavior of the bugged apktool.bat. Notice the version printed: "2.9.3", but in the folder, notice the latest version is "2.12.0".

Here's a screenshot of the output after fixing the script:

image

It now correctly finds the latest version.

@iBotPeaches iBotPeaches merged commit e475f73 into iBotPeaches:master Jul 22, 2025
2 checks passed
@iBotPeaches
Copy link
Owner

thanks!

@iBotPeaches iBotPeaches added this to the 2.12.1 milestone Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants