Skip to content

Added support for gradle 8.8+ and dependencies updated#3053

Open
sumitsharansatsangi wants to merge 31 commits intofzyzcjy:masterfrom
sumitsharansatsangi:master
Open

Added support for gradle 8.8+ and dependencies updated#3053
sumitsharansatsangi wants to merge 31 commits intofzyzcjy:masterfrom
sumitsharansatsangi:master

Conversation

@sumitsharansatsangi
Copy link
Copy Markdown

Changes

Discussion 2987

fzyzcjy and others added 11 commits December 16, 2025 14:46
When oxidized package is detected in pubspec.yaml dependencies:
- Fallible Rust functions return Future<Result<T, E>> instead of Future<T>
- Errors are returned as Err(...) instead of throwing exceptions
- Panics still throw PanicException (bugs, not expected errors)

Runtime (frb_dart):
- Add decodeAsResult() to SimpleDecoder for Result-based decoding
- Add decodeObjectAsResult/decodeWireSyncTypeAsResult to BaseCodec
- Add executeNormalAsResult/executeSyncAsResult to BaseHandler
- Export Result, Ok, Err from flutter_rust_bridge_for_generated_common.dart

Codegen (frb_codegen):
- Add has_dependency() to DartRepository
- Add detect_oxidized_dependency() in generator_parser.rs
- Add use_oxidized field to GeneratorApiDartInternalConfig
- Wrap fallible function return types in Result<T, E>
- Use executeNormalAsResult/executeSyncAsResult for fallible functions

Tested with dart_minimal example:
- Async functions: Future<Result<T, E>>
- Sync functions: Result<T, E>
  When a type alias like \`type Result<T> = std::result::Result<T, MyError>\`
  is used, FRB now correctly extracts the error type from the alias definition
  instead of falling back to AnyhowException.

  - Store generic type aliases separately in HirFlatTypeAlias
  - Look up generic Result aliases when parsing function return types
  - Substitute type parameters to resolve the actual error type
- Add example error types and functions using type aliases
- Update generated Dart/Rust bindings with new test cases
Traits marked with #[frb(ignore)] were being collected into src_traits
but the ignore attribute was never checked, causing panics when the
trait was used in Option<T> contexts.

This mirrors how structs/enums handle the ignore attribute via
parse_struct_or_enum_should_ignore.

Amp-Thread-ID: https://ampcode.com/threads/T-019bf8ee-f69c-75eb-981d-55743289c99e
Co-authored-by: Amp <amp@ampcode.com>
Add first-class support for serde_json::Value as a delegate type that
serializes via JSON string across the FFI boundary, mapping to Dart's
Object?. Supports all codecs (SSE, DCO, CST) and composite types
(Option, Vec, HashMap, struct fields). Includes tests, documentation,
and feature flag gated behind `serde_json`.
Copy link
Copy Markdown

@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 primarily focuses on updating dependencies across various projects, including updates to Android Gradle plugins, Flutter dependencies, and Dart packages. It also introduces improvements to the Cargokit build tool, such as better error handling with custom exceptions, more robust tool resolution, and updated documentation. My feedback highlights critical issues with non-existent Gradle versions and unsupported Android API levels, as well as suggestions for improving cross-platform compatibility in tests and shell scripts.

dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.android.tools.build:gradle:8.13.2'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The Android Gradle Plugin version 8.13.2 does not appear to exist in the official Google or Maven Central repositories. The current stable versions are in the 8.7.x range, and 8.8.0 was recently released. This will likely cause build failures as the dependency cannot be resolved. Please verify if this is a typo (perhaps for 8.3.2 or 8.7.2).

// Bumping the plugin compileSdkVersion requires all clients of this plugin
// to bump the version in their app.
compileSdkVersion 33
compileSdk 37
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

compileSdk 37 refers to an Android API level that is not yet available. Android 15 is API 35, and Android 16 is expected to be API 36. This should likely be set to 35 or 34 to ensure compatibility with current build tools.

Future<ProcessResult> _runCli(List<String> args) {
final dartExecutable = _dartExecutable();
return Process.run(
'/bin/zsh',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Hardcoding /bin/zsh as the executable for running tests will cause failures on Windows environments where Zsh is not installed or located at that path. Since the project explicitly supports Windows (as seen in the CI configuration), consider using a more cross-platform approach, such as checking Platform.isWindows or invoking dart directly if a shell is not strictly required for the test environment.

try {
// Compatibility: Flutter >=3.32.0-0.0.pre
platforms = com.flutter.gradle.FlutterPluginUtils.getTargetPlatforms(project).collect()
} catch (Exception e) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Catching Exception will not handle NoClassDefFoundError, which is thrown if the com.flutter.gradle.FlutterPluginUtils class is missing (which happens when running on older Flutter versions). In Groovy/Gradle scripts, it is safer to catch Throwable to ensure the fallback logic in the catch block is executed correctly.

            } catch (Throwable e) {

Comment on lines +47 to +48
shopt -s expand_aliases
alias shasum="sha1sum"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using an alias in a shell script is generally discouraged as aliases are not expanded in non-interactive shells by default. Although shopt -s expand_aliases is used here, defining a function is more robust and idiomatic for providing command wrappers in shell scripts.

Suggested change
shopt -s expand_aliases
alias shasum="sha1sum"
shasum() {
sha1sum "$@"
}

Comment on lines +43 to +44
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There is an inconsistency in the Java version used across example projects. This file uses VERSION_17, while frb_example/flutter_package/android/build.gradle was updated to VERSION_21. It is recommended to standardize on one version (e.g., VERSION_17 for broader compatibility or VERSION_21 for the latest LTS) across all examples to maintain consistency.

@sumitsharansatsangi
Copy link
Copy Markdown
Author

/gemini review

Copy link
Copy Markdown

@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 updates the cargokit submodule to a personal fork, bumps Android SDK requirements (compileSdk to 37, minSdk to 24) and Java compatibility versions, and includes various dependency updates and refactorings in the build_tool package. My feedback highlights concerns regarding the use of a personal fork for the submodule, requests clarification on the breaking changes to Android SDK requirements, and suggests using the direct execution method for shell scripts to ensure proper interpreter usage.

Comment thread .gitmodules
Comment on lines +3 to +6
url = https://github.com/sumitsharansatsangi/cargokit.git
[submodule "frb_codegen/assets/integration_template/app/rust_builder/cargokit"]
path = frb_codegen/assets/integration_template/app/rust_builder/cargokit
url = https://github.com/fzyzcjy/cargokit
url = https://github.com/sumitsharansatsangi/cargokit.git
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

This PR changes the cargokit submodule to point to a personal fork (sumitsharansatsangi/cargokit.git). For long-term maintainability and to avoid potential issues if the personal fork becomes unavailable, it would be better to either:

  1. Get the necessary changes merged into the upstream fzyzcjy/cargokit repository.
  2. Move the fork to a neutral organization repository if upstream merging is not feasible.

Could you clarify if this is a temporary change for the PR or intended to be permanent?

Comment on lines 42 to 49
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}

defaultConfig {
minSdkVersion 19
minSdk 24
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

These changes significantly increase the minimum requirements for Android projects using this template:

  • minSdk is increased from 19 to 24. This is a breaking change that will affect which devices can run applications using this template.
  • sourceCompatibility and targetCompatibility are updated to JavaVersion.VERSION_21 from VERSION_1_8.

These changes should be clearly communicated in the PR description and any relevant documentation.

I also noticed some inconsistencies across the updated build.gradle files in this PR:

  • frb_example/flutter_via_create/rust_builder/android/build.gradle updates Java compatibility to VERSION_17.
  • frb_example/flutter_via_integrate/rust_builder/android/build.gradle doesn't change Java compatibility or minSdk.

It would be good to align these for consistency.

done

"$BASEDIR/run_build_tool.sh" build-pod "$@"
sh "$BASEDIR/run_build_tool.sh" build-pod "$@"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using sh explicitly to run the script is a good practice for portability. However, since run_build_tool.sh has a #!/usr/bin/env bash shebang, it might be more robust to execute it directly without sh to ensure it's interpreted by bash as intended, especially if it uses bash-specific features.

Suggested change
sh "$BASEDIR/run_build_tool.sh" build-pod "$@"
"$BASEDIR/run_build_tool.sh" build-pod "$@"

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 71.88498% with 176 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.67%. Comparing base (67bfaec) to head (36df2ef).
⚠️ Report is 620 commits behind head on master.

Files with missing lines Patch % Lines
...src/library/codegen/parser/mir/parser/ty/result.rs 23.80% 32 Missing ⚠️
frb_dart/lib/src/cli/build_web/executor.dart 28.20% 28 Missing ⚠️
...rator/wire/rust/spec_generator/misc/ty/delegate.rs 18.18% 9 Missing ⚠️
...gen/src/library/codegen/parser/mir/parser/ty/ty.rs 91.08% 9 Missing ⚠️
..._codegen/src/library/commands/cargo_expand/real.rs 52.63% 9 Missing ⚠️
...st/spec_generator/codec/cst/decoder/ty/delegate.rs 0.00% 6 Missing ⚠️
...en/src/library/codegen/parser/hir/flat/exporter.rs 84.21% 6 Missing ⚠️
...brary/codegen/parser/mir/parser/ty/trait_object.rs 0.00% 5 Missing ⚠️
frb_codegen/src/library/commands/flutter.rs 0.00% 5 Missing ⚠️
frb_dart/lib/src/codec/sse.dart 72.22% 5 Missing ⚠️
... and 34 more
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3053       +/-   ##
===========================================
- Coverage   98.57%   72.67%   -25.91%     
===========================================
  Files         464      465        +1     
  Lines       19202    13752     -5450     
===========================================
- Hits        18928     9994     -8934     
- Misses        274     3758     +3484     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fzyzcjy
Copy link
Copy Markdown
Owner

fzyzcjy commented Apr 6, 2026

Great job! there looks like a lot of diff, if this is not needed, maybe can firstly reset/merge your branch from the main master branch

# Conflicts:
#	frb_dart/lib/src/codec/dco.dart
#	frb_dart/pubspec.yaml
#	frb_example/dart_minimal/pubspec.lock
#	frb_example/dart_minimal/pubspec.yaml
#	frb_example/dart_minimal/rust/src/frb_generated.rs
@sumitsharansatsangi
Copy link
Copy Markdown
Author

/gemini review

Copy link
Copy Markdown

@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 introduces support for the "oxidized" Dart package, enabling fallible Rust functions to return Result types in Dart instead of throwing exceptions. It also implements robust support for generic type aliases, deep equality checks for collection types, and updates the integrated cargokit tool. Other notable changes include splitting the Naive time delegate into NaiveDate and NaiveDateTime, adding support for serde_json::Value, and performing extensive dependency updates. Feedback focuses on improving error handling by replacing a panic with a proper error result, removing redundant alias resolution logic, and extending generic parameter substitution to support additional Rust type variants.

Comment thread frb_codegen/src/library/codegen/parser/mir/parser/ty/optional.rs
Comment on lines +17 to 38
Some((type_name, args)) => {
// Check if this is a Result type directly OR a type alias that resolves to Result
let is_result = type_name == &"Result";
let is_result_alias = !is_result && is_result_type_alias(type_parser, type_name);

if is_result || is_result_alias {
// Check if this might be a generic type alias like `type Result<T> = std::result::Result<T, MyError>`
// or `type WResult<T> = std::result::Result<T, MyError>`
// If we only have one arg, try to resolve the error type from the alias definition
let resolved_args = if args.len() == 1 {
resolve_generic_result_alias_args(type_parser, type_name, args)
} else {
None
};

let args_to_parse = resolved_args.as_deref().unwrap_or(args);
let parsed_args = (args_to_parse.iter())
.map(|arg| type_parser.parse_type(arg, context))
.collect::<anyhow::Result<Vec<_>>>()?,
);
.collect::<anyhow::Result<Vec<_>>>()?;
return parse_type_result(&parsed_args);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This logic for resolving generic Result aliases is redundant because TypeParserWithContext::parse_type already resolves all type aliases (including generic ones) before calling parse_type_maybe_result. Furthermore, the local substitute_type_param implementation is less robust than the centralized one in ty.rs as it lacks recursion. This redundant logic should be removed to simplify the codebase.

Comment thread frb_codegen/src/library/codegen/parser/mir/parser/ty/ty.rs
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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