Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Android Gradle build tools to 8.5.2 and compileSdk to 35 #118

Merged
merged 4 commits into from
Feb 20, 2025

Conversation

tuancoltech
Copy link
Member

@tuancoltech tuancoltech commented Feb 19, 2025

Issue Number

Purpose

  • Upgrade Android Gradle Plugin to 8.1.x.
  • Update compileSdk to 35
  • Upgrade Java compile/target version to 17

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Upgraded the Android build configuration to target SDK version 35.
    • Updated the Android Gradle plugin to version 8.5.2 for enhanced features and stability.
    • Updated Gradle to version 8.12 for improved build performance.
    • Refined the Java version matrix in the build workflow to include Java versions 17 and 21 for better compatibility.
    • Enhanced error handling and compliance in the Gradle wrapper scripts.

@tuancoltech tuancoltech requested a review from a team as a code owner February 19, 2025 16:07
Copy link

coderabbitai bot commented Feb 19, 2025

Walkthrough

This update modifies the Android project’s build configuration. In the app module’s Gradle file, the target SDK version is increased from 32 to 35, the applicationId is removed in favor of a new namespace declaration ("ai.elimu.vitabu"), and the build feature for generating a BuildConfig class is enabled. Additionally, the top-level build script updates the Android Gradle plugin version from 7.1.2 to 8.5.2, and the Gradle wrapper’s distribution URL is updated from version 7.4 to 8.12. The Java compatibility settings are also updated from version 11 to 17. The GitHub Actions workflow is updated to include Java versions 17 and 21.

Changes

File(s) Change Summary
app/build.gradle Updated compileSdk from 32 to 35, removed applicationId from defaultConfig, added namespace "ai.elimu.vitabu", updated sourceCompatibility and targetCompatibility from Java 11 to Java 17, and enabled buildConfig.
build.gradle Upgraded Android Gradle plugin version from 7.1.2 to 8.5.2.
gradle/wrapper/gradle-wrapper.properties Updated the Gradle distribution URL from version 7.4 to 8.12, added networkTimeout set to 10000, and added validateDistributionUrl set to true.
.github/workflows/gradle-build.yml Updated Java version matrix from [11, 17] to [17, 21].
gradlew Modified for POSIX compliance, updated error handling, and improved argument processing.
gradlew.bat Enhanced error handling, added licensing information, and set default JVM options.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Gradle as Gradle Build System
    participant AGP as Android Gradle Plugin
    participant Builder as Build Process

    Dev->>Gradle: Initiate build
    Gradle->>AGP: Load app/build.gradle configuration
    AGP->>Gradle: Process compileSdk, namespace, buildConfig settings
    Gradle->>Builder: Trigger BuildConfig generation
    Builder->>Gradle: Build tasks execute
    Gradle->>Dev: Complete build process
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
app/build.gradle (1)

40-43: 🛠️ Refactor suggestion

⚠️ Potential issue

Update Java Compatibility:
The compileOptions block still specifies JavaVersion.VERSION_11. Since AGP 8.1.4 requires Java 17, this discrepancy is likely causing build failures (as indicated by the pipeline error). Please update the Java compatibility to Java 17.

Diff suggestion:

-        sourceCompatibility JavaVersion.VERSION_11
-        targetCompatibility JavaVersion.VERSION_11
+        sourceCompatibility JavaVersion.VERSION_17
+        targetCompatibility JavaVersion.VERSION_17
🧹 Nitpick comments (1)
app/build.gradle (1)

4-5: SDK and Namespace Update:
The changes to update the SDK and package structure are clear:

  • compileSdk is now set to 35, which aligns with the latest APIs.
  • A new namespace "ai.elimu.vitabu" has been introduced for better modularization and future-proofing.

Note: Review the targetSdkVersion in the defaultConfig (currently at 32) to ensure it aligns with the updated compileSdk if that is intended.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c42c0ea and 8166632.

📒 Files selected for processing (3)
  • app/build.gradle (2 hunks)
  • build.gradle (1 hunks)
  • gradle/wrapper/gradle-wrapper.properties (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • gradle/wrapper/gradle-wrapper.properties
🧰 Additional context used
🪛 GitHub Actions: Gradle Build
build.gradle

[error] 1-1: Android Gradle plugin requires Java 17 to run. You are currently using Java 11.

app/build.gradle

[error] 1-1: Android Gradle plugin requires Java 17 to run. You are currently using Java 11.

🔇 Additional comments (2)
build.gradle (1)

11-11: AGP Version Upgrade:
The Android Gradle Plugin version has been correctly updated to 8.1.4. Please note that AGP 8.1.4 requires Java 17 to run. Ensure your build environment (and any related CI/CD configurations) is updated accordingly to avoid runtime issues.

app/build.gradle (1)

44-47: Build Features Update:
Enabling the generation of a BuildConfig class by setting buildConfig = true is a good practice with the updated AGP. This change should streamline build configuration management.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 19, 2025
Copy link
Member

@jo-elimu jo-elimu left a comment

Choose a reason for hiding this comment

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

@tuancoltech The build checks are failing.

@tuancoltech
Copy link
Member Author

@tuancoltech The build checks are failing.

@jo-elimu I fixed the build error just now.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 20, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 20, 2025
@@ -1,6 +1,6 @@
#Thu Feb 24 11:21:45 PST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
Copy link
Member

Choose a reason for hiding this comment

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

If you use the Gradle Upgrade Manager, or the ./gradlew wrapper --gradle-version x.x.x command, I think more files would be affected?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jo-elimu You're correct.
In fact, both ways are OK.
I usually just update the distributionUrl to avoid extra changes, but it seems the more recommended way is to run gradlew wrapper command.
Ref: https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:upgrading_wrapper

Maybe I'll take this chance to upgrade this wrapper via command as per you suggested.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jo-elimu Updated now using the command instead.

* Upgrade Gradle wrapper version to 8.12
* Add Java 21 to Action build script
@tuancoltech tuancoltech changed the title Upgrade AGP to 8.1 and compileSdk to 35 Upgrade Android Gradle build tools to 8.5.2 and compileSdk to 35 Feb 20, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
gradlew (1)

144-161: Limited utility for “maximum” file descriptors on POSIX.

The ulimit -H -n approach is standard, but some distros may not allow raising the limit without explicit admin privileges. This won’t break the script, but it may produce warnings.

gradlew.bat (1)

37-37: Consider adjusting default memory settings.

Defaulting to -Xmx64m and -Xms64m might be low for larger Android Gradle builds on Java 17. Consider raising the heap size (e.g., 128m or 256m) to prevent potential build failures.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3584490 and f234b30.

⛔ Files ignored due to path filters (1)
  • gradle/wrapper/gradle-wrapper.jar is excluded by !**/*.jar
📒 Files selected for processing (5)
  • .github/workflows/gradle-build.yml (1 hunks)
  • build.gradle (1 hunks)
  • gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • gradlew (2 hunks)
  • gradlew.bat (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • build.gradle
  • .github/workflows/gradle-build.yml
  • gradle/wrapper/gradle-wrapper.properties
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: build (macos-latest, 21)
  • GitHub Check: build (macos-latest, 17)
  • GitHub Check: build (ubuntu-latest, 21)
  • GitHub Check: build (ubuntu-latest, 17)
🔇 Additional comments (8)
gradlew (4)

1-16: Ensure consistent shell availability.

Switching the shebang to #!/bin/sh is standard for POSIX compliance, but on some systems /bin/sh might be a minimal shell lacking certain features. It's worth verifying that all required POSIX features listed in the comments are indeed supported by /bin/sh on your target distributions.


68-82: Symlink resolution logic looks good.

The updated approach to resolve symlinks via app_path and a case statement is more robust and avoids deprecated constructs. No issues found.


119-141: Validate Java detection and error messages.

The script checks both $JAVA_HOME and the presence of the java command. This is solid logic and gracefully fails with a clear error message if Java is missing. Be sure to keep this consistent with the required Java 17 environment for the updated AGP version.


162-247: Check availability of xargs on minimal systems.

Requiring xargs is generally fine, but minimal environments might not have it installed by default. The script already handles this by failing fast and prompting the user. This approach is acceptable; just be aware of potential friction in very constrained build environments.

gradlew.bat (4)

1-16: License header inclusion is correct.

Including the Apache License 2.0 header at the start of the batch script is good practice. No issues found.


28-35: Path resolution improvement.

Shortening %APP_HOME% via the loop helps avoid edge cases with relative paths. This makes the script more robust across Windows environments.


44-50: Error handling alignment.

Switching to if %ERRORLEVEL% equ 0 and redirecting messages to 1>&2 is a best practice for batch scripts, ensuring clear user feedback.


58-65: Validation of JAVA_HOME directory.

Verifying %JAVA_EXE% exists before proceeding avoids silent failures. This aligns well with your Java 17 requirement.

@tuancoltech tuancoltech requested a review from jo-elimu February 20, 2025 13:07
@tuancoltech tuancoltech merged commit 5c89729 into main Feb 20, 2025
6 checks passed
@tuancoltech tuancoltech deleted the build/upgrade_agp branch February 20, 2025 15:12
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.

Upgrade to Gradle 8.x
2 participants