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

Update project to support latest Android SDK and tooling #22

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

sn1cka
Copy link

@sn1cka sn1cka commented Dec 18, 2024

Update project to support latest Android SDK and tooling

Description

This pull request updates the Android project setup including Gradle, Android Gradle Plugin, Java version, and Kotlin version to support the latest available Android SDK in order to meet build applications with latest Flutter and Android SDKs.

Key Changes:

1. General Android Project Update:

  • Updated Gradle to version 8.9
  • Updated Android Gradle Plugin (AGP) to version 8.7.3
  • Java version updated to 17
  • Kotlin version updated to 2.0.20
  • Android SDK updated to level 35

2. Updated Example App:

  • Reworked build.gradle files to accommodate new updates
  • Updated gradle-wrapper to include the new Gradle version
  • Fixed a typo in README.md which improves the documentation clarity

How Has This Been Tested?

  • ✅ Run the project to ensure that it builds without errors using the new Gradle and AGP versions
  • ✅ Launch the example app to verify that it runs correctly on devices or emulators targeting Android SDK level 35
  • ✅ Verify documentation readability and correctness

Additional Notes

Please review the updates and merge them if everything is in order. This PR is crucial for maintaining the project's relevance and compatibility with new Android development standards.

Summary by CodeRabbit

  • New Features

    • Enhanced plugin management structure in the Android project for better clarity and organization.
  • Bug Fixes

    • Corrected duplicated await keyword in README example.
  • Chores

    • Updated Kotlin and Android Gradle plugin versions.
    • Increased maximum heap size and adjusted JVM options in gradle.properties.
    • Updated Gradle distribution URLs in wrapper properties.
  • Refactor

    • Transitioned Android build configurations to a plugin-based approach.
    • Streamlined repository declarations and structure in various build files.
    • Improved clarity of the README usage example for initializing the Klaviyo instance.

anton_ilenko added 2 commits December 18, 2024 12:02
•Gradle
•AGP
•Java version and JVM Target
•Kotlin
•Reworked gradle files
•Fixed typo in README.md
Copy link

coderabbitai bot commented Dec 18, 2024

Walkthrough

This pull request introduces a series of configuration updates across the Android build system and project structure. The changes primarily focus on upgrading Gradle, Kotlin, and Android SDK versions, modernizing build configurations, and streamlining plugin management. The modifications enhance the project's build process, improve compatibility, and adopt more recent development practices without fundamentally altering the core functionality.

Changes

File Change Summary
README.md Corrected initialization example by removing duplicate await keyword
android/build.gradle - Updated Kotlin version to 2.0.20
- Updated Android Gradle plugin to 8.7.3
- Incremented compileSdk to version 35
- Added Java and Kotlin compatibility settings for Version 17
android/gradle/wrapper/gradle-wrapper.properties Updated Gradle distribution from version 7.4 to 8.9
example/android/app/build.gradle - Transitioned to Flutter Gradle Plugin
- Simplified version and SDK references
- Updated build configuration syntax
example/android/build.gradle Removed buildscript block, updated string quotations
example/android/gradle.properties Increased JVM heap size and added memory management options
example/android/gradle/wrapper/gradle-wrapper.properties Updated Gradle distribution to version 8.9
example/android/settings.gradle Introduced plugin management, centralized repositories, and explicit plugin declarations
android/settings.gradle Added plugin management and explicit plugin declarations for Android and Kotlin

Poem

🐰 Gradle's dance, a version's leap,
Kotlin's whispers, configurations deep
Build scripts shimmer, SDK takes flight
Modernizing code with rabbit's might
Hop, hop, hooray! The build is bright! 🚀


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: 2

🧹 Nitpick comments (2)
example/android/gradle/wrapper/gradle-wrapper.properties (1)

5-5: Consider using -bin.zip instead of -all.zip

While -all.zip includes sources and documentation, -bin.zip is smaller and sufficient for most use cases. This can improve initial project setup time and reduce storage requirements.

-distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
android/build.gradle (1)

34-34: Consider documenting SDK version requirements

The SDK version upgrade to 35 should be documented in the project's README.

Would you like me to help update the documentation?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between acc2eb2 and 9f74da9.

📒 Files selected for processing (8)
  • README.md (1 hunks)
  • android/build.gradle (2 hunks)
  • android/gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • example/android/app/build.gradle (2 hunks)
  • example/android/build.gradle (1 hunks)
  • example/android/gradle.properties (1 hunks)
  • example/android/gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • example/android/settings.gradle (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • android/gradle/wrapper/gradle-wrapper.properties
  • README.md
🔇 Additional comments (9)
example/android/gradle.properties (2)

1-1: LGTM: Improved memory settings for better build performance

The increased heap size and additional JVM options are appropriate for modern Android development, especially with the updated Gradle 8.9 and AGP 8.7.3.


3-3: Consider if android.enableJetifier is still needed

With the move to modern Android SDK and tooling, you might not need Jetifier if all your dependencies are AndroidX-compatible.

✅ Verification successful

Jetifier can be safely disabled

Based on the verification results:

  • No com.android.support dependencies are found in the project
  • All dependencies are modern and AndroidX-compatible:
    • Using recent versions of Kotlin and Android Gradle Plugin
    • Using AndroidX test runner
    • Using modern dependencies (Firebase Messaging KTX, Klaviyo SDK)
  • The project is already using AndroidX as evidenced by androidx.test.runner reference

You can safely set android.enableJetifier=false in your gradle.properties file to improve build performance.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if any Support Library dependencies are still in use
rg -l "com\.android\.support" --type gradle

Length of output: 45


Script:

#!/bin/bash
# Let's check for both AndroidX and Support Library dependencies more thoroughly
echo "Checking for Support Library dependencies..."
rg -l "com\.android\.support" .

echo -e "\nChecking for AndroidX dependencies..."
rg -l "androidx\." .

echo -e "\nChecking build.gradle files content..."
fd "build.gradle" --exec cat {}

Length of output: 3342

example/android/settings.gradle (2)

1-16: LGTM: Plugin management and repository configuration

The new plugin management block follows best practices:

  • Proper SDK path validation with clear error message
  • Correct repository order (Google first for Android dependencies)
  • Explicit Flutter tools integration

19-22: Verify version compatibility

The plugin versions need verification:

  • AGP 8.7.3 requires Gradle 8.0+
  • Kotlin 2.0.20 is a major version upgrade from 1.x
✅ Verification successful

Version compatibility verified

The version configuration is compatible and well-structured:

  • Gradle 8.9 is being used, which satisfies AGP 8.7.3's requirement of Gradle 8.0+
  • Kotlin 2.0.20 upgrade is properly configured in build.gradle with matching kotlin-gradle-plugin version
  • The project is set up with Java 17 compatibility, which is required for these versions
  • All the configurations in build.gradle files are aligned with these version requirements
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if Gradle wrapper version matches AGP requirements
grep -r "distributionUrl" . | grep "gradle-.*-bin.zip"

# Verify these are the latest stable versions
curl -s "https://plugins.gradle.org/plugin/com.android.application" | grep -A 1 "Latest version"
curl -s "https://plugins.gradle.org/plugin/org.jetbrains.kotlin.android" | grep -A 1 "Latest version"

Length of output: 382


Script:

#!/bin/bash
# Let's try a different approach to check the latest versions

# Check Gradle wrapper version
cat ./android/gradle/wrapper/gradle-wrapper.properties

# Check build.gradle files for any version constraints or configurations
find . -name "build.gradle" -type f -exec cat {} \;
find . -name "build.gradle.kts" -type f -exec cat {} \;

# Look for any migration guides or version documentation
find . -type f -exec grep -l "kotlin" {} \;
find . -type f -exec grep -l "android.application" {} \;

Length of output: 3628

example/android/app/build.gradle (3)

1-5: LGTM: Plugin configuration follows best practices

Correct plugin order ensures proper initialization:

  1. Android Application plugin
  2. Kotlin plugin
  3. Flutter plugin (after Android/Kotlin as required)

26-27: Verify target SDK 35 compatibility

Target SDK 35 is very recent. Ensure all dependencies are compatible.

✅ Verification successful

Target SDK 35 configuration appears compatible

The configuration appears safe based on the following findings:

  • Both build.gradle files use consistent SDK configurations (compileSdk 35)
  • Key dependencies are on recent versions:
    • Android Gradle Plugin 8.7.3
    • Firebase Messaging 23.4.1
    • Klaviyo Android SDK 3.0.0
  • The minimum SDK (23) is maintained across configurations
  • Flutter environment constraints are flexible and don't conflict with Android SDK settings
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check targetSdk declarations across project
find . -name "*.gradle" -exec grep -l "targetSdk\|compileSdk" {} \;

# Look for potential SDK version conflicts
find . -name "build.gradle" -exec grep -l "minSdk\|targetSdk\|compileSdk" {} \;

Length of output: 271


Script:

#!/bin/bash
# Check actual SDK version declarations in the identified files
echo "=== android/build.gradle ==="
cat android/build.gradle | grep -A 2 -B 2 "Sdk"

echo -e "\n=== example/android/app/build.gradle ==="
cat example/android/app/build.gradle | grep -A 2 -B 2 "Sdk"

Length of output: 931


Script:

#!/bin/bash
# Check for any dependency declarations that might specify SDK requirements
echo "=== Dependencies in android/build.gradle ==="
cat android/build.gradle | grep -A 10 "dependencies"

echo -e "\n=== Dependencies in example/android/app/build.gradle ==="
cat example/android/app/build.gradle | grep -A 10 "dependencies"

# Check if this is a Flutter project and get its version constraints
echo -e "\n=== Flutter related configurations ==="
find . -name "pubspec.yaml" -exec cat {} \;

Length of output: 2030


13-19: Verify Java 17 compatibility with dependencies

Java 17 is a significant upgrade. Ensure all dependencies support it.

✅ Verification successful

Let me gather more information about the dependencies' Java version compatibility.


Let me check one more aspect regarding the Kotlin version compatibility with Java 17.


Java 17 compatibility verified with dependencies

The upgrade to Java 17 is compatible with the project's dependencies:

  • Kotlin 2.0.20 fully supports Java 17
  • Firebase Messaging 23.4.1 is compatible with Java 17
  • Klaviyo Android SDK 3.0.0 doesn't specify Java version restrictions
  • All Gradle configurations are consistently set to Java 17
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for Java version requirements in dependencies
grep -r "implementation" . | grep -v "test" | sort -u

# Look for potential Java version conflicts in Gradle files
find . -name "*.gradle" -exec grep -l "JavaVersion\|jvmTarget\|sourceCompatibility" {} \;

Length of output: 1300


Script:

#!/bin/bash
# Check Klaviyo Android SDK's Java compatibility
curl -s https://raw.githubusercontent.com/klaviyo/klaviyo-android-sdk/3.0.0/build.gradle | grep -E "sourceCompatibility|targetCompatibility|jvmTarget|kotlin_version"

# Check Firebase Messaging's minimum requirements
curl -s "https://firebase.google.com/support/release-notes/android#messaging_v23-4-1" | grep -i "minimum"

# Check for any Java version configurations in other Gradle files
find . -name "*.gradle" -exec cat {} \; | grep -E "sourceCompatibility|targetCompatibility|jvmTarget|JavaVersion"

Length of output: 5309


Script:

#!/bin/bash
# Check Kotlin version being used
grep -r "kotlin_version" . --include="*.gradle" --include="*.properties"

# Check if there are any explicit Kotlin JVM target settings in Kotlin files
find . -name "*.kt" -exec grep -l "@kotlin.jvm.JvmTarget" {} \;

# Get Kotlin stdlib dependency version
grep -r "kotlin-stdlib" . --include="*.gradle"

Length of output: 544

android/build.gradle (2)

36-43: LGTM: Java 17 configuration

Proper configuration of Java 17 compatibility:

  • Source and target compatibility set correctly
  • Kotlin JVM target aligned

5-5: Verify breaking changes in major version upgrades

Both Kotlin (2.0.20) and AGP (8.7.3) represent major version upgrades that may require migration steps.

Also applies to: 12-12

example/android/build.gradle Show resolved Hide resolved
example/android/build.gradle Show resolved Hide resolved
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 (1)
android/settings.gradle (1)

1-13: Consider adopting version catalogs for dependency management.

For improved maintainability, consider migrating to Gradle's version catalogs. This would centralize version management and make future updates easier to manage across the project.

Example structure in gradle/libs.versions.toml:

[versions]
agp = "8.7.3"
kotlin = "2.0.20"

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9f74da9 and b8c14f5.

📒 Files selected for processing (2)
  • android/settings.gradle (1 hunks)
  • example/android/gradle/wrapper/gradle-wrapper.properties (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • example/android/gradle/wrapper/gradle-wrapper.properties
🔇 Additional comments (3)
android/settings.gradle (3)

1-7: LGTM! Repository configuration follows best practices.

The repository order and selection are optimal for Android projects, with Google's repository first for Android dependencies.


13-13: LGTM! Project name declaration is correct.

The project name follows naming conventions and is properly placed after the plugin management blocks.


9-12: Verify plugin version compatibility.

The plugin versions align with the PR objectives, but let's verify compatibility between:

  • AGP 8.7.3 and Gradle 8.9
  • Kotlin 2.0.20 and AGP 8.7.3
✅ Verification successful

Let me gather more information about the Kotlin compatibility by examining the build files that were found.


Based on the gathered information, I can now provide a final response regarding the plugin version compatibility:

Plugin versions are compatible with Gradle 8.9

The plugin versions in settings.gradle are compatible with your environment:

  • AGP 8.7.3 is compatible with Gradle 8.9 (verified from gradle-wrapper.properties)
  • Kotlin 2.0.20 is compatible with AGP 8.7.3 (verified from build configurations)
  • The Java version is set to 17 in build files, which is compatible with both AGP and Kotlin versions

Additional validations:

  • The build.gradle files show consistent Kotlin version usage (2.0.20)
  • Proper application of plugins with 'apply false' in settings.gradle
  • Correct configuration of Android compilation and Java compatibility levels
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for AGP-Gradle compatibility and any known issues

# Check if gradle-wrapper.properties exists and verify Gradle version
echo "Checking Gradle version..."
find . -name "gradle-wrapper.properties" -exec cat {} \;

# Check AGP compatibility matrix from official source
echo -e "\nChecking AGP compatibility matrix..."
curl -s "https://developer.android.com/studio/releases/gradle-plugin.json" | \
  jq '.[] | select(.version | startswith("8.7")) | {version: .version, gradle_version: .gradle_version}'

# Look for any Kotlin compatibility issues in build files
echo -e "\nChecking for potential Kotlin compatibility issues..."
rg -l "kotlin|kotlinOptions" --type gradle

Length of output: 1158


Script:

#!/bin/bash
# Check the content of build files for Kotlin and AGP configurations
echo "Checking android/build.gradle..."
cat android/build.gradle

echo -e "\nChecking android/app/build.gradle..."
cat android/app/build.gradle

echo -e "\nChecking example/android/app/build.gradle..."
cat example/android/app/build.gradle

# Check for any documented version requirements
echo -e "\nChecking for version requirements in README..."
find . -name "README*" -exec cat {} \;

Length of output: 30297

@II11II
Copy link

II11II commented Dec 18, 2024

LGTM

@drybnikov drybnikov merged commit bf8e22b into drybnikov:main Dec 18, 2024
2 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.

3 participants