Skip to content

Conversation

@nini22P
Copy link
Collaborator

@nini22P nini22P commented Aug 10, 2025

No description provided.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @nini22P, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've implemented a fix to prevent Android's Asset Packaging Tool (AAPT) from decompressing .gz files that are part of the application's assets. This ensures that pre-compressed .gz files remain compressed within the APK, which is crucial for their correct handling by the application.

Highlights

  • Android Asset Compression Control: I've configured aaptOptions in app/build.gradle to specifically prevent the compression of files with the .keep_gz extension. This is a key step to ensure that our .gz files are not inadvertently decompressed by the build system.
  • Dynamic File Renaming During Build: I've added build logic within applicationVariants.all that renames .gz files to .keep_gz before AAPT processes them (doFirst), and then renames them back to .gz after processing for the final APK and also reverts the source files (doLast). This clever trick allows us to bypass AAPT's default compression behavior for these files.
  • Reusable File Renaming Utility: A new renameFiles helper function has been introduced to encapsulate the logic for renaming files based on their directory path and extensions. This promotes cleaner and more maintainable build scripts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to prevent .gz files in assets from being decompressed by Android's build tools. The approach involves renaming files before the asset merging task and renaming them back after. While the idea is valid, the implementation has several critical issues. Firstly, it uses the applicationVariants API, which is removed in the version of the Android Gradle Plugin used by this project, causing a build failure. Secondly, it modifies source files directly, which is a dangerous practice that can corrupt the source tree. Lastly, the file renaming logic is flawed and can lead to incorrect filenames. I've provided detailed comments on how to address these issues.

aaptOptions {
noCompress['.keep_gz']
}
applicationVariants.all { variant ->

Choose a reason for hiding this comment

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

critical

The applicationVariants.all API was removed in Android Gradle Plugin (AGP) 8.0. Since your project is configured with AGP 8.9.0 (as per your root build.gradle), this code will cause a build failure. You need to migrate to the new androidComponents extension to iterate over variants. The approach to modifying assets is different with this new API, and it typically involves creating custom tasks and wiring them into the variant's asset processing pipeline. You can find more details in the AGP migration guide.

applicationVariants.all { variant ->
variant.mergeAssetsProvider.configure {
doFirst {
renameFiles("${projectDir}/src/main/assets", ".gz", ".keep_gz")

Choose a reason for hiding this comment

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

high

Modifying source files directly from your build script is a risky practice. If the build fails after this doFirst block but before the corresponding doLast block (line 55) runs, your source files in src/main/assets will be left in a renamed state. This can cause issues with your version control system and break subsequent builds.

A safer approach is to work with files in an intermediate directory inside build/. This ensures your source tree remains untouched by the build process.

Comment on lines 63 to 66
fileTree(dir: dirPath, include: "**/*" + fromExt).each { file ->
def renamedFile = new File(file.parent, file.name.replace(fromExt, toExt))
file.renameTo(renamedFile)
}

Choose a reason for hiding this comment

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

high

Using String.replace() here is not safe for renaming file extensions, as it will replace all occurrences of the substring. For example, a file named my.gz.file.gz would be incorrectly renamed to my.keep_gz.file.keep_gz. You should only replace the extension at the end of the filename. This can be done by checking endsWith() first.

    fileTree(dir: dirPath, include: "**/*" + fromExt).each { file ->
        if (file.name.endsWith(fromExt)) {
            def newName = file.name.substring(0, file.name.length() - fromExt.length()) + toExt
            file.renameTo(new File(file.parent, newName))
        }
    }

@nini22P nini22P merged commit d2d2698 into OpenWebGAL:main Aug 10, 2025
3 checks passed
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.

1 participant