-
Notifications
You must be signed in to change notification settings - Fork 368
chore(samples): upgrade android gradle plugin and dependencies #2375
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
Conversation
This commit upgrades the Android Gradle Plugin and related dependencies in the sample application. Key changes: - Upgraded Gradle wrapper to version 8.10.2. - Updated Android Gradle Plugin to 8.7.0. - Updated Kotlin Gradle Plugin to 2.1.0. - Updated `com.google.gms.google-services` to 4.3.10. - Updated `desugar_jdk_libs` to 2.0.4. - Updated NDK version to 27.0.12077973. - Refactored `app/build.gradle` to align with modern Flutter Android project structure, including: - Using `flutter.compileSdkVersion`, `flutter.minSdkVersion`, `flutter.targetSdkVersion`, `flutter.versionCode`, and `flutter.versionName` for configuration. - Setting `sourceCompatibility` and `targetCompatibility` to `JavaVersion.VERSION_11`. - Setting `kotlinOptions.jvmTarget` to `JavaVersion.VERSION_11.toString()`. - Removed `settings_aar.gradle` as it is no longer needed. - Updated `build.gradle` to use `rootProject.layout.buildDirectory` instead of `rootProject.buildDir`. - Ensured subprojects align their `compileSdkVersion` with `flutter.compileSdkVersion`. - Set the namespace for all subprojects if not already set.
This commit updates the Firebase configurations for the sample application across various platforms and files. Key changes include: - **`firebase.json`**: New file added, defining Firebase project IDs and app IDs for Android, iOS, macOS, and Dart. - **`sample_app/macos/Runner/GoogleService-Info.plist`**: Updated `ANDROID_CLIENT_ID`. - **`sample_app/lib/firebase_options.dart`**: - Updated `apiKey`, `appId`, and `measurementId` for `web` FirebaseOptions. - Updated `appId` for `android` FirebaseOptions. - Updated `androidClientId` for both `ios` and `macos` FirebaseOptions. - **`sample_app/android/app/google-services.json`**: - Updated `client_id` and `ios_info.bundle_id` for multiple client entries. - Added new client entries with updated `mobilesdk_app_id` and `package_name`. - **`sample_app/ios/Runner/GoogleService-Info.plist`**: Updated `ANDROID_CLIENT_ID`.
WalkthroughIntroduces FlutterFire/Google Services to the sample app, updates Android Gradle plugins and wrapper, aligns SDK/namespace and Kotlin/Java targets, switches to Flutter-provided Android config, refreshes desugaring libs, and updates Firebase credentials/config across Android, iOS, macOS, and Dart. Removes legacy Gradle settings and afterEvaluate logic. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant Gradle as Gradle Build
participant GMS as Google Services Plugin
participant App as Android App
participant Firebase as Firebase SDK
Dev->>Gradle: Run assemble/debug
Gradle->>GMS: Apply google-services plugin
GMS->>Gradle: Parse google-services.json and generate resources
Gradle->>App: Merge generated resources and configs
App->>Firebase: Initialize with firebase_options.dart at runtime
Firebase-->>App: Services available (Auth/Analytics/etc.)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45–70 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (12)
sample_app/android/gradle/wrapper/gradle-wrapper.properties (1)
6-6
: Add wrapper checksum for supply‑chain hardening.
Include distributionSha256Sum to verify the downloaded Gradle distribution.Apply this diff:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip +distributionSha256Sum=<paste SHA-256 for gradle-8.10.2-all.zip>
Reference: Gradle docs recommend checksum verification for the wrapper. (docs.gradle.org)
sample_app/lib/firebase_options.dart (1)
46-56
: Heads‑up: Gitleaks false positive on Firebase Web API key.
Firebase apiKey/measurementId here are expected in client apps and aren’t secrets; keep rules locked down server‑side. If these aren’t test creds, confirm intent.Static analysis flagged these lines as GCP keys; acknowledge and proceed if this is a sample project configuration.
sample_app/android/settings.gradle (1)
21-26
: Versioning sanity check + recommended bumps.
- AGP 8.7.0 + Gradle 8.10.2 are compatible; JDK 17 is required. (developer.android.com)
- Kotlin Gradle Plugin 2.1.0 is compatible with AGP 8.7.x and Gradle ≤ 8.10. (kotlinlang.org)
- Please bump Google Services plugin from 4.3.10 to the current 4.4.3. (developers.google.com)
Apply this diff:
- id "com.google.gms.google-services" version "4.3.10" apply false + id "com.google.gms.google-services" version "4.4.3" apply falsesample_app/android/build.gradle (4)
8-8
: Prefer property setters for Layout API.
Use .set(...) to avoid Groovy coercion pitfalls.-rootProject.layout.buildDirectory = "../build" +rootProject.layout.buildDirectory.set(file("../build"))
10-10
: Ditto for subproject build directories.- project.layout.buildDirectory = rootProject.layout.buildDirectory.dir(project.name) + project.layout.buildDirectory.set(rootProject.layout.buildDirectory.dir(project.name))
12-21
: Avoid afterEvaluate; set Android DSL via plugin hooks and use compileSdk (not compileSdkVersion).
- afterEvaluate can cause ordering issues.
- compileSdkVersion is deprecated in favor of compileSdk. (developer.android.com)
- afterEvaluate { project -> - if (project.hasProperty("android")) { - // Set the namespace for all subprojects if not set - if (android.namespace == null) { - android.namespace = project.group - } - - // Align the compileSdkVersion with Flutter's compileSdkVersion - android.compileSdkVersion = flutter.compileSdkVersion - } - } + plugins.withId("com.android.application") { + android { + // Only set if missing; prefer explicit namespace per module. + if (namespace == null && project.group) { + namespace = "${project.group}.${project.name}" + } + compileSdk = flutter.compileSdkVersion + } + } + plugins.withId("com.android.library") { + android { + if (namespace == null && project.group) { + namespace = "${project.group}.${project.name}" + } + compileSdk = flutter.compileSdkVersion + } + }
26-26
: evaluationDependsOn(':app') may slow configuration.
Unless you rely on :app’s evaluated values, consider removing it.sample_app/android/app/build.gradle (3)
13-14
: Use compileSdk instead of compileSdkVersion.
AGP DSL favors compileSdk. (developer.android.com)- compileSdkVersion flutter.compileSdkVersion + compileSdk = flutter.compileSdkVersion
51-55
: Migrate APK renaming to androidComponents API.
applicationVariants is legacy; prefer onVariants/onVariantProperties to avoid deprecation risk in AGP 9+. (developer.android.com)Example (KTS shown; adapt to Groovy if desired):
androidComponents { onVariants { v -> v.outputs.forEach { out -> out.outputFileName.set("flutter-sample-app-${v.name}.apk") } } }
63-64
: Update desugaring libs.
2.1.5 is current; consider upgrading. (mvnrepository.com)- coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'sample_app/android/app/google-services.json (2)
244-245
: API key hygiene: ensure restriction + rotation policy.google-services.json is public-safe, but confirm this key is restricted to the Firebase project and Android package+SHA-1 signers. Rotate if any unintended exposure is suspected.
Also applies to: 544-545, 616-617, 652-653, 688-689
229-264
: Trim unused google-services.json client for compose "pntest.debug".Gradle defaultConfig (sample_app/android/app/build.gradle) declares applicationId "io.getstream.chat.android.flutter.sample", while google-services.json contains a client for "io.getstream.chat.android.compose.sample.pntest.debug" — remove the client block in sample_app/android/app/google-services.json (lines 229–264) unless that appId is intentionally built/used.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (10)
sample_app/android/app/build.gradle
(2 hunks)sample_app/android/app/google-services.json
(14 hunks)sample_app/android/build.gradle
(1 hunks)sample_app/android/gradle/wrapper/gradle-wrapper.properties
(1 hunks)sample_app/android/settings.gradle
(1 hunks)sample_app/android/settings_aar.gradle
(0 hunks)sample_app/firebase.json
(1 hunks)sample_app/ios/Runner/GoogleService-Info.plist
(1 hunks)sample_app/lib/firebase_options.dart
(3 hunks)sample_app/macos/Runner/GoogleService-Info.plist
(1 hunks)
💤 Files with no reviewable changes (1)
- sample_app/android/settings_aar.gradle
🧰 Additional context used
🪛 Gitleaks (8.27.2)
sample_app/lib/firebase_options.dart
[high] 47-47: Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.
(gcp-api-key)
[high] 58-58: Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.
(gcp-api-key)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: stream_chat_flutter
- GitHub Check: stream_chat_flutter_core
- GitHub Check: stream_chat
- GitHub Check: stream_chat_localizations
- GitHub Check: stream_chat_persistence
🔇 Additional comments (13)
sample_app/android/gradle/wrapper/gradle-wrapper.properties (1)
6-6
: Gradle 8.10.2 is compatible with AGP 8.7 — good upgrade.
AGP 8.7 requires Gradle ≥ 8.9; 8.10.2 fits. Also aligns with NDK 27 default. (developer.android.com)sample_app/lib/firebase_options.dart (2)
57-65
: Android appId update looks consistent with firebase.json.
No action; just ensure google‑services.json under android/app matches this appId.
66-76
: iOS/macOS OAuth client IDs updated — verify sign‑in flows.
Confirm Google Sign‑In still works on iOS/macOS after client swap.sample_app/android/build.gradle (1)
29-31
: LGTM on Layout API for clean.
Uses rootProject.layout.buildDirectory correctly.sample_app/android/app/build.gradle (3)
3-5
: Google Services plugin: align with 4.4.3.
You declare the version in settings.gradle; after bumping there, this stays as‑is. Just noting the required root change. (developers.google.com)
14-15
: NDK version matches AGP guidance — good.
AGP 8.7 defaults to NDK 27.0.12077973. (developer.android.com)
26-32
: DefaultConfig via Flutter ext looks good.
Min SDK gate to 23 is fine with desugaring.sample_app/ios/Runner/GoogleService-Info.plist (1)
10-10
: Confirm OAuth alignment.
ANDROID_CLIENT_ID changed; ensure it matches firebase_options.dart and any Google Sign‑In configuration in code.sample_app/macos/Runner/GoogleService-Info.plist (1)
10-10
: Confirm macOS OAuth alignment.
Same as iOS — verify sign‑in still succeeds with the new client.sample_app/firebase.json (1)
1-40
: FlutterFire config looks coherent across platforms.
IDs here match the generated Dart/options; outputs point to the right files.sample_app/android/app/google-services.json (3)
591-596
: New Android client for io.getstream.expotiktokapp added—verify it belongs here.If this app isn’t part of this sample’s variants, remove this client. If it is, ensure app/build.gradle’s applicationId matches exactly so the Google Services plugin resolves the right stanza.
Also applies to: 601-636
307-311
: Consistent OAuth client swap (…36up).The repeated client_id replacement looks systematic. Double‑check the matching OAuth/Web credentials exist in the same Firebase project to avoid Sign‑In/Invites mismatches.
Also applies to: 343-347, 379-383, 415-419, 459-463, 511-515, 555-559, 591-596
51-55
: Confirm cross‑project iOS bundle_id in google-services.jsonFound a single ios bundle_id in sample_app/android/app/google-services.json: io.getstream.expotiktokapp. Confirm this is intentional (shared Firebase project). If not intentional, revert the appinvite.other_platform_oauth_client ios_info.bundle_id entries to the expected bundle_id(s) to avoid credential drift.
This PR upgrades the Android Gradle Plugin and related dependencies in the sample application.
Key changes:
com.google.gms.google-services
to 4.3.10.desugar_jdk_libs
to 2.0.4.app/build.gradle
to align with modern Flutter Android project structure, including:flutter.compileSdkVersion
,flutter.minSdkVersion
,flutter.targetSdkVersion
,flutter.versionCode
, andflutter.versionName
for configuration.sourceCompatibility
andtargetCompatibility
toJavaVersion.VERSION_11
.kotlinOptions.jvmTarget
toJavaVersion.VERSION_11.toString()
.settings_aar.gradle
as it is no longer needed.build.gradle
to userootProject.layout.buildDirectory
instead ofrootProject.buildDir
.compileSdkVersion
withflutter.compileSdkVersion
.Summary by CodeRabbit
New Features
Chores