-
Notifications
You must be signed in to change notification settings - Fork 32
fix: build errors with Flutter 3.35.0 and update dependencies #35
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
base: master
Are you sure you want to change the base?
Conversation
fix: build errors with flutter 3.35.0 or superior
fix: build errors with flutter 3.35.0 or superior
WalkthroughUpdates a Flutter usage statistics plugin from version 1.3.1 to 1.3.2 with Kotlin 2.2.0, AGP 8.13.0, Gradle 8.13, and iOS platform 13.0 support. Restructures Android build configuration to use plugin management, rewrites test suite with centralized MethodChannel mocking, adds changelog entry for Flutter 3.35.0 compatibility fix, and marks plugin as Android-only in iOS podspec. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Runner
participant Binding as TestDefaultBinaryMessengerBinding
participant Channel as MethodChannel
participant MockHandler as Mock MethodCallHandler
Note over Test,MockHandler: Old Flow: Per-Call Handler
Test->>Channel: Setup channel
Test->>Channel: Invoke method (isUsagePermission)
Channel->>MockHandler: Handle call
Note over Test,MockHandler: New Flow: Centralized Logging
Test->>Binding: Initialize with central handler
Binding->>MockHandler: Register global mock handler
Test->>Test: Add test for checkUsagePermission
Test->>Channel: Invoke isUsagePermission
Channel->>MockHandler: Handle call
MockHandler->>MockHandler: Log to global list
MockHandler-->>Channel: Return predefined payload
Channel-->>Test: Return result
Test->>Test: Verify MethodCall in global log
Test->>Binding: Teardown & reset handler
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (2)
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: 5
🧹 Nitpick comments (1)
.idea/workspace.xml (1)
1-1028: IDE configuration files should not be committed to version control.The provided files are all IntelliJ IDEA IDE configuration and workspace state files from the
.idea/directory (deviceManager.xml, markdown.xml, Dart_SDK.xml library paths, deviceStreaming.xml cache, and workspace.xml). These files are:
- Auto-generated or environment-specific
- Developer-machine dependent (paths, UI state, device selections, run configurations)
- Already excluded in most Flutter projects via
.gitignoreRecommendation: Add or update
.gitignoreto exclude the entire.idea/directory (or at minimum the caches, workspace, and auto-managed configs). These changes should not be part of the PR since they clutter the changeset with environment noise and will conflict with other developers' local IDE states.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
example/pubspec.lockis excluded by!**/*.lock
📒 Files selected for processing (20)
.idea/caches/deviceStreaming.xml(1 hunks).idea/deviceManager.xml(1 hunks).idea/libraries/Dart_SDK.xml(1 hunks).idea/markdown.xml(1 hunks).idea/misc.xml(0 hunks).idea/workspace.xml(2 hunks)CHANGELOG.md(1 hunks)android/build.gradle(3 hunks)android/gradle/wrapper/gradle-wrapper.properties(1 hunks)example/android/app/build.gradle(3 hunks)example/android/app/src/main/AndroidManifest.xml(1 hunks)example/android/build.gradle(0 hunks)example/android/gradle/wrapper/gradle-wrapper.properties(1 hunks)example/android/settings.gradle(1 hunks)example/ios/Flutter/ephemeral/flutter_lldb_helper.py(1 hunks)example/ios/Flutter/ephemeral/flutter_lldbinit(1 hunks)example/pubspec.yaml(1 hunks)ios/usage_stats.podspec(1 hunks)pubspec.yaml(2 hunks)test/usage_stats_test.dart(1 hunks)
💤 Files with no reviewable changes (2)
- .idea/misc.xml
- example/android/build.gradle
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
CHANGELOG.md
5-5: Multiple headings with the same content
(MD024, no-duplicate-heading)
🪛 Ruff (0.14.5)
example/ios/Flutter/ephemeral/flutter_lldb_helper.py
7-7: Unused function argument: bp_loc
(ARG001)
7-7: Unused function argument: extra_args
(ARG001)
7-7: Unused function argument: intern_dict
(ARG001)
🔇 Additional comments (16)
example/pubspec.yaml (1)
21-21: LGTM!Adding
flutter_lints: ^6.0.0to the example's dev dependencies is a best practice for maintaining code quality. This aligns with Flutter ecosystem standards.example/android/gradle/wrapper/gradle-wrapper.properties (1)
6-6: Verify Gradle wrapper distribution consistency across modules.The example module uses
-bin.zipwhile the plugin'sandroid/gradle/wrapper/gradle-wrapper.propertiesuses-all.zip. Confirm this divergence is intentional or align both distributions.pubspec.yaml (1)
3-3: LGTM!The version bump to 1.3.2 and the iOS platform entry with
pluginClass: nonecorrectly declare this as an Android-only plugin while acknowledging iOS platform support. This is the idiomatic way to mark platform-specific implementations in Flutter plugins.Also applies to: 24-25
android/gradle/wrapper/gradle-wrapper.properties (1)
5-5: Verify Gradle wrapper distribution strategy.The plugin uses
gradle-8.13-all.zipwhile the example usesgradle-8.13-bin.zip. Confirm this is intentional (e.g., plugin development may benefit from sources) or standardize across both modules.example/android/app/src/main/AndroidManifest.xml (1)
8-8: LGTM!The application label update from "example" to "usageStats" improves the example app's branding and clarity.
android/build.gradle (2)
5-5: Verify Kotlin 2.2.0 and compileSdkVersion 36 compatibility with plugin code.This file introduces significant version bumps:
- Kotlin 1.9.0 → 2.2.0 (major version)
- compileSdkVersion 30 → 36 (+6 SDK levels)
- kotlinx-coroutines-android 1.5.2 → 1.10.2
Ensure the plugin's Kotlin code (not provided in this review) is compatible with Kotlin 2.2.0 features and deprecations, and that compileSdkVersion 36 doesn't introduce API incompatibilities. The coroutines upgrade is generally backward-compatible, but confirm no APIs used have been removed.
Also applies to: 11-11, 28-28, 53-53
8-8: LGTM!The migration from
jcenter()tomavenCentral()is a best practice and aligns with the ecosystem's shift after jcenter's deprecation.Also applies to: 19-19
example/android/app/build.gradle (2)
1-5: LGTM!The declarative plugin block (lines 1–5) follows modern Gradle conventions. Using Flutter-managed SDK versions (line 48) is a best practice that reduces version drift and simplifies configuration.
Also applies to: 48-48
68-68: Align kotlin-stdlib version with root build.gradle.Line 68 hardcodes
kotlin-stdlib-jdk7:2.1.0, whileandroid/build.gradlespecifies Kotlin 2.2.0 via$kotlin_version. This version mismatch could cause transitive dependency conflicts. Align both to the same Kotlin version or use a shared variable.Consider updating to match the root Kotlin version:
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.0" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.2.0"Alternatively, if 2.1.0 is intentional (e.g., for forward compatibility testing), document the reason in a comment.
test/usage_stats_test.dart (5)
93-96: LGTM! Proper test cleanup.The tearDown correctly resets the mock method call handler, ensuring a clean state between tests.
98-115: LGTM! Comprehensive permission tests.Both permission-related methods are properly tested with verification of return values and method call logging.
117-264: Excellent comprehensive test coverage for query and network methods.The test suite thoroughly covers:
- All query methods with proper type assertions and field validation
- Network usage stats with multiple network type scenarios
- Proper verification of method call arguments including timestamps and network types
The tests follow good practices by verifying both the returned data structure and the method channel invocation details.
8-90: Mock setup correctly matches platform implementation—no changes needed.Verification of the Kotlin implementation confirms the test mock is accurate. All numeric values in the platform channel are explicitly converted to strings via
.toString()in UsageStats.kt, NetworkStats.kt, and passed through directly in UsageStatsPlugin.kt. The mock responses in test/usage_stats_test.dart correctly return string values for timestamps, counts, byte sizes, and other numeric fields, precisely matching what the actual platform channel provides to Flutter.
266-278: The NetworkType enum values are correctly verified and match the Android implementation.The Dart enum values (all=1, wifi=2, mobile=3) match exactly what the Kotlin implementation expects. In
android/src/main/kotlin/io/github/parassharmaa/usage_stats/NetworkStats.kt, the code maps incoming type values viawhen (type): 1→All, 2→WiFi, 3→Mobile. These values are intentionally abstracted application-level constants rather than direct Android ConnectivityManager constants, and the mapping is consistent across platforms. The tests are accurate.example/android/settings.gradle (2)
1-17: LGTM! Modern pluginManagement configuration.The pluginManagement block properly resolves the Flutter SDK path from
local.propertiesand includes the Flutter Gradle tooling. The repository configuration (google, mavenCentral, gradlePluginPortal) follows best practices.
19-25: Modern plugin-based Gradle configuration aligns with Flutter 3.35.0+.The declarative plugins block with the Flutter plugin loader (version 1.0.0), Android application plugin (8.13.1), and explicit module inclusion (":app") follows the modern Gradle approach required for Flutter 3.35.0+.
CHANGELOG.md
Outdated
| ## 1.3.1 | ||
|
|
||
| * Fix build errors with flutter 3.35.0 or superior | ||
|
|
||
| ## 1.3.1 | ||
|
|
||
| * Fix build errors with flutter 3.29.0 |
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.
Fix duplicate CHANGELOG section heading.
Lines 1–5 create two ## 1.3.1 headings, which violates Markdown standards (MD024) and creates ambiguity in the version history. Consolidate both fixes under a single 1.3.1 section or clarify if they target different version numbers.
## 1.3.1
* Fix build errors with flutter 3.35.0 or superior
+ * Fix build errors with flutter 3.29.0
- ## 1.3.1
-
- * Fix build errors with flutter 3.29.0📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ## 1.3.1 | |
| * Fix build errors with flutter 3.35.0 or superior | |
| ## 1.3.1 | |
| * Fix build errors with flutter 3.29.0 | |
| ## 1.3.1 | |
| * Fix build errors with flutter 3.35.0 or superior | |
| * Fix build errors with flutter 3.29.0 | |
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
5-5: Multiple headings with the same content
(MD024, no-duplicate-heading)
🤖 Prompt for AI Agents
In CHANGELOG.md around lines 1 to 7 there are two identical "## 1.3.1" headings;
consolidate them by merging the bullet points under a single "## 1.3.1" section
(or, if one entry was meant for a different version, correct that heading to the
appropriate version) so the changelog contains only one unique heading per
version and the two fix lines are combined or correctly versioned.
| plugins { | ||
| id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
| id "com.android.application" version "8.13.1" apply false | ||
| id "org.jetbrains.kotlin.android" version "2.1.0" apply false | ||
| } |
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.
🧩 Analysis chain
Verify Kotlin version inconsistency with PR summary.
The PR summary states Kotlin is updated to 2.2.0, but this file declares version 2.1.0. Ensure consistency across all Gradle configuration files.
🏁 Script executed:
#!/bin/bash
# Check Kotlin version declarations across all Gradle files
rg -n 'kotlin.*version|ext.kotlin_version' --type=gradle -g '*.gradle' -g 'gradle.properties'Length of output: 359
Update Kotlin version to 2.2.0 in example/android/settings.gradle.
The Kotlin plugin version in example/android/settings.gradle:22 is hardcoded to 2.1.0, but android/build.gradle:5 declares ext.kotlin_version = '2.2.0'. Update line 22 to version 2.1.0 to match the version declared in the main build configuration.
🤖 Prompt for AI Agents
In example/android/settings.gradle around lines 19 to 23 the Kotlin plugin is
pinned to "2.1.0" while the main android/build.gradle sets ext.kotlin_version =
'2.2.0'; update the Kotlin plugin line (id "org.jetbrains.kotlin.android"
version "2.1.0" apply false) to use version "2.2.0" so both files match.
| # | ||
| # Generated file, do not edit. | ||
| # | ||
|
|
||
| import lldb | ||
|
|
||
| def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict): | ||
| """Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages.""" | ||
| base = frame.register["x0"].GetValueAsAddress() | ||
| page_len = frame.register["x1"].GetValueAsUnsigned() | ||
|
|
||
| # Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the | ||
| # first page to see if handled it correctly. This makes diagnosing | ||
| # misconfiguration (e.g. missing breakpoint) easier. | ||
| data = bytearray(page_len) | ||
| data[0:8] = b'IHELPED!' | ||
|
|
||
| error = lldb.SBError() | ||
| frame.GetThread().GetProcess().WriteMemory(base, data, error) | ||
| if not error.Success(): | ||
| print(f'Failed to write into {base}[+{page_len}]', error) | ||
| return | ||
|
|
||
| def __lldb_init_module(debugger: lldb.SBDebugger, _): | ||
| target = debugger.GetDummyTarget() | ||
| # Caveat: must use BreakpointCreateByRegEx here and not | ||
| # BreakpointCreateByName. For some reasons callback function does not | ||
| # get carried over from dummy target for the later. | ||
| bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$") | ||
| bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__)) | ||
| bp.SetAutoContinue(True) | ||
| print("-- LLDB integration loaded --") |
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.
Generated ephemeral file should not be committed to version control.
Like its companion file flutter_lldbinit, this auto-generated LLDB helper script resides in an ephemeral directory and should be excluded from version control. Flutter regenerates these debugging support files automatically during builds.
The static analysis warnings about unused function arguments (bp_loc, extra_args, intern_dict) in handle_new_rx_page are false positives—these parameters are part of LLDB's callback signature and must be present even if unused.
Ensure the ephemeral directory is properly ignored:
+example/ios/Flutter/ephemeral/Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 Ruff (0.14.5)
7-7: Unused function argument: bp_loc
(ARG001)
7-7: Unused function argument: extra_args
(ARG001)
7-7: Unused function argument: intern_dict
(ARG001)
🤖 Prompt for AI Agents
In example/ios/Flutter/ephemeral/flutter_lldb_helper.py lines 1-32: this is an
auto-generated ephemeral LLDB helper that should not be committed and its unused
callback parameters (bp_loc, extra_args, intern_dict) are required by LLDB; to
fix, add the ephemeral directory (example/ios/Flutter/ephemeral/) to your
repository .gitignore (or appropriate pattern), remove any already-committed
generated files with git rm --cached <path> and commit the .gitignore update,
and keep the function signature as-is; optionally, if static analysis must be
silenced, add a linter-ignore comment for unused arguments in that file (rather
than changing the signature).
| # | ||
| # Generated file, do not edit. | ||
| # | ||
|
|
||
| command script import --relative-to-command-file flutter_lldb_helper.py |
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.
Generated ephemeral files should not be committed to version control.
This file is auto-generated by Flutter tooling (as indicated by the header comment) and resides in an ephemeral directory, which by convention contains temporary build artifacts. Committing generated files introduces unnecessary noise in version history and can cause merge conflicts.
Additionally, the PR objectives state this plugin is Android-only, making these iOS debugging files unnecessary in the repository.
Add the following to your .gitignore:
+example/ios/Flutter/ephemeral/Or if you need finer control:
+example/ios/Flutter/ephemeral/flutter_lldbinit
+example/ios/Flutter/ephemeral/flutter_lldb_helper.pyCommittable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In example/ios/Flutter/ephemeral/flutter_lldbinit lines 1-5: this is a
generated, ephemeral Flutter iOS debug file that should not be committed for an
Android-only plugin; remove the file from the commit and add the ephemeral path
(e.g., example/ios/Flutter/ephemeral/ or the specific flutter_lldbinit filename)
to .gitignore so generated iOS ephemeral files are ignored in future commits;
ensure the removal is only from version control (not needed in repo) and update
.gitignore with the appropriate pattern.
| # This plugin is Android-only and does not support iOS. | ||
| Pod::Spec.new do |s| | ||
| s.name = 'usage_stats' | ||
| s.version = '0.0.1' | ||
| s.summary = 'A new Flutter plugin.' | ||
| s.summary = 'Android-only plugin for usage statistics.' | ||
| s.description = <<-DESC | ||
| A new Flutter plugin. | ||
| This plugin is Android-only and does not support iOS. | ||
| DESC | ||
| s.homepage = 'http://example.com' | ||
| s.homepage = 'https://github.com/Parassharmaa/usage_stats' | ||
| s.license = { :file => '../LICENSE' } | ||
| s.author = { 'Your Company' => 'email@example.com' } | ||
| s.author = { 'Paras Sharma' => 'parassharmaa@gmail.com' } | ||
| s.source = { :path => '.' } | ||
| s.source_files = 'Classes/**/*' | ||
| s.dependency 'Flutter' | ||
| s.platform = :ios, '8.0' | ||
| s.platform = :ios, '13.0' | ||
|
|
||
| # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. | ||
| s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } | ||
| s.swift_version = '5.0' | ||
| s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } | ||
| s.swift_version = '5.9' |
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.
Inconsistent iOS configuration for an Android-only plugin.
The podspec declares this is an "Android-only plugin" (lines 5, 9, 11) but still specifies iOS platform requirements (iOS 13.0) and Swift version (5.9). This creates confusion about the plugin's actual platform support.
Additionally, the podspec version is 0.0.1 while the PR summary indicates version 1.3.2.
Consider one of the following approaches:
Option 1: Minimal/stub podspec (if iOS should be completely unsupported):
Pod::Spec.new do |s|
s.name = 'usage_stats'
s.version = '1.3.2'
s.summary = 'Android-only plugin for usage statistics.'
s.description = <<-DESC
This plugin is Android-only and does not support iOS.
DESC
s.homepage = 'https://github.com/Parassharmaa/usage_stats'
s.license = { :file => '../LICENSE' }
s.author = { 'Paras Sharma' => 'parassharmaa@gmail.com' }
s.source = { :path => '.' }
# Minimal iOS config to satisfy CocoaPods
s.platform = :ios, '12.0'
# Empty source files
s.source_files = []
endOption 2: Remove iOS-specific claims (if iOS will be supported later):
Remove "Android-only" descriptions and keep current configuration for future iOS support.
🤖 Prompt for AI Agents
ios/usage_stats.podspec lines 5-22: the podspec claims "Android-only" while
still declaring iOS platform and Swift version and also uses version 0.0.1
instead of 1.3.2; fix by choosing one of two approaches: Option A (Android-only
stub) — update s.version to 1.3.2, keep the descriptive text that it does not
support iOS, set minimal CocoaPods fields (keep s.platform to a low iOS min like
12.0 if required), and make s.source_files empty (or remove iOS-specific
settings like s.swift_version and s.pod_target_xcconfig) so the pod is
effectively a no-op on iOS; Option B (support iOS) — remove the "Android-only"
wording, update s.version to 1.3.2, and keep/validate the existing s.platform
and s.swift_version and ensure s.source_files points to actual iOS sources.
Apply one consistent choice and update the version to 1.3.2.
Remove ephemeral Flutter LLDB helper files that should not be tracked in version control. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ral files to .gitignore fix: Prevent Flutter debug helper files from being tracked in version control.
Summary
This PR fixes build errors with Flutter 3.35.0 or higher and updates project dependencies to the latest stable versions.
Changes Made
Gradle Configuration (Migration to Declarative Blocks)
pluginManagementandplugins {}blockexample/android/settings.gradlewith new structureexample/android/build.gradleremoving obsoletebuildscriptexample/android/app/build.gradleto use declarative pluginsAndroid Native Dependencies
1.9.0→2.2.08.1.2→8.13.0/8.13.18.3→8.13jcenter()(deprecated) withmavenCentral()kotlinx-coroutines-androidto1.10.2Flutter Dependencies
flutter_lints: ^6.0.0to examplepubspec.yamlthat the plugin is Android-onlyTests
setMockMethodCallHandler()to modern APIcheckUsagePermission,grantUsagePermission)queryEvents,queryConfiguration,queryEventStats,queryUsageStats,queryAndAggregateUsageStats)queryNetworkUsageStats,queryNetworkUsageStatsByPackage)NetworkTypeextensioniOS
ios/usage_stats.podspec(iOS 13.0, Swift 5.9)Compatibility
This PR ensures compatibility with:
Testing
Summary by CodeRabbit
Release Notes v1.3.2
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.