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

fix: Shorebird Detects Native Changes Incorrectly When Patching #2930

Open
varoxez8 opened this issue Feb 27, 2025 · 7 comments
Open

fix: Shorebird Detects Native Changes Incorrectly When Patching #2930

varoxez8 opened this issue Feb 27, 2025 · 7 comments
Labels
bug Something isn't working waiting for response Waiting for customer response

Comments

@varoxez8
Copy link

varoxez8 commented Feb 27, 2025

App ID: 3fd68888-654c-4831-abbc-d9e2fc4000a0

Description

I am encountering an issue where shorebird patch android fails, stating that there are native changes detected, despite:
• No modifications in the android/ or ios/ directories.
• Using the same Flutter and Shorebird versions as the original release.
• All dependencies being locked in pubspec.yaml and pubspec.lock.
• The same shorebird release android command being used successfully in previous builds.

Steps To Reproduce

  1. Initial Release: Successfully release an Android version using:
    shorebird release android
    --flutter-version=3.24.5
    --flavor production
    --target ./lib/main_prod.dart

  2. Make Dart-Only Changes: Modify only Dart code (e.g., UI logic, business logic, etc.), ensuring no native dependency changes.

  3.  Try to Patch: Run:           
    

source $CM_ENV
echo "ANDROID_VERSION:$ANDROID_VERSION"
echo "IOS_VERSION:$IOS_VERSION"
shorebird patch android
--target lib/main_prod.dart
--flavor production
--release-version="$ANDROID_VERSION"
4. Issue Occurs: Shorebird refuses to patch, stating native changes detected. although it works for ios but for android it says

✓ Building patch with Flutter 3.24.5 (3faf56aafa) (365.0s)
⠋ Verifying patch can be applied to release...
✓ Verifying patch can be applied to release (51ms)
[WARN] Your app contains native changes, which cannot be applied with a patch.
Changed files:
base/dex/classes.dex
base/dex/classes2.dex

If you don't know why you're seeing this error, visit our troubleshooting page at https://docs.shorebird.dev/troubleshooting
Instance of 'UnpatchableChangeException'

Expected Behavior

Shorebird should allow Dart-only patches if there are no native changes in android/ or ios/.

Actual Behavior
Shorebird detects false native changes and prevents patching.

Additional Notes
• If there’s any known workaround for this, please let me know.
• If required, I can provide additional debug logs or try experimental fixes.
• I am using code magic.

@varoxez8 varoxez8 added the bug Something isn't working label Feb 27, 2025
@felangel
Copy link
Contributor

felangel commented Feb 27, 2025

Hi @varoxez8 👋
Thanks for filing an issue!

Are you able to share a link to a minimal reproduction sample on GitHub? It would also be helpful to see a list of your native dependencies (or just your pubspec.yaml). Thanks!

@felangel felangel added the waiting for response Waiting for customer response label Feb 27, 2025
@varoxez8
Copy link
Author

varoxez8 commented Feb 27, 2025

Hello @felangel
i can't trigger it everytime but also that blocking me from patching fixes to my previous releases which are created using shorebird release
this is my pubspec.yaml file

name: clickandcollectflutter
description: A new Flutter project.

publish_to: 'none' 

version: 365.6.4+473

environment:
  sdk: ">=3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: 0.20.0

  cupertino_icons: 1.0.8
  flutter_svg: 2.0.10+1
  auto_route: 8.1.3
  lottie: 3.1.2
  visibility_detector: 0.4.0+2
  carousel_slider: 5.0.0
  animated_text_kit: 4.2.2
  flutter_native_splash: 2.4.0
  flutter_displaymode: 0.6.0
  flutter_spinkit: 5.2.1
  pinput: 4.0.0
  shimmer: 3.0.0
  smooth_page_indicator: 1.0.0+2
  auto_size_text: 3.0.0
  flutter_staggered_animations: 1.1.1
  confetti: 0.8.0
  fluttertoast: "8.2.8"
  flutter_slidable: 3.1.2
  scroll_to_index: 3.0.1
  get_it: 8.0.2
  injectable: 2.5.0
  equatable: 2.0.3
  json_annotation: 4.9.0
  provider: 6.1.2
  mobx: 2.5.0
  flutter_mobx: 2.2.1+1
  rxdart: 0.27.4
  timezone: 0.9.3
  async: 2.11.0
  upgrader: 11.3.0
  url_launcher: 6.2.6
  flutter_image_compress: 2.3.0
  image_picker: 1.1.1
  infinite_scroll_pagination: 4.0.0
  http: 1.2.1
  socket_io_client: 2.0.0
  algolia: 1.1.2
  cached_network_image: 3.3.1
  timeago: 3.6.1
  path: 1.9.0
  app_links: 6.3.2

  dio: 5.4.3+1
  permission_handler: 11.3.1
  internet_connection_checker_plus: 2.5.2
  
  device_info_plus: 11.1.1
  printing: 5.12.0

  google_maps_flutter: 2.2.3

  # Local Storage Packages
  hive: 2.2.3
  hive_flutter: 1.1.0
  shared_preferences: 2.2.3

  firebase_core: 3.8.0
  firebase_crashlytics: 4.1.5
  firebase_app_check: 0.3.1+6
  firebase_database: 11.1.6
  firebase_auth: 5.3.3
  firebase_messaging: 15.1.5
  firebase_analytics: 11.3.5
  firebase_storage: 12.3.6
  cloud_firestore: 5.5.0
  firebase_remote_config: 5.1.5
  sms_autofill: 2.3.1

  flutter_local_notifications: 18.0.1

  webview_flutter: 4.10.0
  flutter_inappwebview: 6.1.5

  adamsdartutilities:
    git:
      url: https://github.com/Chefspartner/adamsdartutilities.git
      ref: master
      version: 1.0.80
  



  

dependency_overrides:
  http: 0.13.5
  intl: 0.18.1
  uuid: 3.0.5




dev_dependencies:


  # Build Packages
  build_runner: 2.4.13
  json_serializable: 6.9.0
  injectable_generator: 2.6.2
  mobx_codegen: 2.7.0
  freezed: 2.5.7
  hive_generator: 2.0.1

  # Code Generation Packages
  auto_route_generator: 8.0.0
  places_service: 0.1.3

  # Linting Packages
  flutter_lints: 4.0.0

  # Icon Packages
  flutter_launcher_icons: "0.13.1"


# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:
  generate: true
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  assets:
    - env/
    - assets/
    - assets/icons/
    - assets/images/category/
    - assets/lottie/
    - assets/google-maps/
    - assets/images/
    - shorebird.yaml
  uses-material-design: true
  fonts:
    - family: 'Montserrat'
      fonts:
        - asset: assets/fonts/Montserrat-Black.ttf
          weight: 900
        - asset: assets/fonts/Montserrat-ExtraBold.ttf
          weight: 800
        - asset: assets/fonts/Montserrat-Bold.ttf
          weight: 700
        - asset: assets/fonts/Montserrat-SemiBold.ttf
          weight: 600
        - asset: assets/fonts/Montserrat-Medium.ttf
          weight: 500
        - asset: assets/fonts/Montserrat-Regular.ttf
          weight: 400
        - asset: assets/fonts/Montserrat-Light.ttf
          weight: 300
        - asset: assets/fonts/Montserrat-ExtraLight.ttf
          weight: 200
        - asset: assets/fonts/Montserrat-Thin.ttf
          weight: 100
        - asset: assets/fonts/Montserrat-BlackItalic.ttf
          weight: 900
          style: italic
        - asset: assets/fonts/Montserrat-ExtraBoldItalic.ttf
          weight: 800
          style: italic
        - asset: assets/fonts/Montserrat-BoldItalic.ttf
          weight: 700
          style: italic
        - asset: assets/fonts/Montserrat-SemiBoldItalic.ttf
          weight: 600
          style: italic
        - asset: assets/fonts/Montserrat-MediumItalic.ttf
          weight: 500
        - asset: assets/fonts/Montserrat-Italic.ttf
          weight: 400
          style: italic
        - asset: assets/fonts/Montserrat-LightItalic.ttf
          weight: 300
          style: italic
        - asset: assets/fonts/Montserrat-ThinItalic.ttf
          weight: 200
          style: italic
        - asset: assets/fonts/Montserrat-ExtraLightItalic.ttf
          weight: 100
          style: italic
    - family: 'Mulish'
      fonts:
        - asset: assets/fonts/Mulish-Black.ttf
          weight: 900
        - asset: assets/fonts/Mulish-ExtraBold.ttf
          weight: 800
        - asset: assets/fonts/Mulish-Bold.ttf
          weight: 700
        - asset: assets/fonts/Mulish-SemiBold.ttf
          weight: 600
        - asset: assets/fonts/Mulish-Medium.ttf
          weight: 500
        - asset: assets/fonts/Mulish-Regular.ttf
          weight: 400
        - asset: assets/fonts/Mulish-Light.ttf
          weight: 300
        - asset: assets/fonts/Mulish-ExtraLight.ttf
          weight: 200
          style: italic
        - asset: assets/fonts/Mulish-BlackItalic.ttf
          weight: 900
          style: italic
        - asset: assets/fonts/Mulish-ExtraBoldItalic.ttf
          weight: 800
          style: italic
        - asset: assets/fonts/Mulish-BoldItalic.ttf
          weight: 700
          style: italic
        - asset: assets/fonts/Mulish-SemiBoldItalic.ttf
          weight: 600
          style: italic
        - asset: assets/fonts/Mulish-MediumItalic.ttf
          weight: 500
          style: italic
        - asset: assets/fonts/Mulish-Italic.ttf
          weight: 400
          style: italic
        - asset: assets/fonts/Mulish-LightItalic.ttf
          weight: 300
          style: italic
        - asset: assets/fonts/Mulish-ExtraLightItalic.ttf
          weight: 200
          style: italic
    - family: 'proximanova'
      fonts:
        - asset: assets/fonts/proximanova-Black.otf
          weight: 900
        - asset: assets/fonts/proximanova-BlackItalic.otf
          weight: 900
          style: italic
        - asset: assets/fonts/proximanova-ExtraBold.otf
          weight: 800
        - asset: assets/fonts/proximanova-ExtraBoldItalic.otf
          weight: 800
          style: italic
        - asset: assets/fonts/proximanova-Bold.otf
          weight: 700
        - asset: assets/fonts/proximanova-BoldItalic.otf
          weight: 700
          style: italic
        - asset: assets/fonts/proximanova-SemiBold.otf
          weight: 600
        - asset: assets/fonts/proximanova-SemiBoldItalic.otf
          weight: 600
          style: italic
        # - asset: assets/fonts/proximanova-Medium.otf
        #   weight: 500
        # - asset: assets/fonts/proximanova-MediumItalic.otf
        #   weight: 500
        #   style: italic
        - asset: assets/fonts/proximanova-Regular.otf
          weight: 400
        - asset: assets/fonts/proximanova-RegularItalic.otf
          weight: 400
          style: italic
        - asset: assets/fonts/proximanova-Light.otf
          weight: 300
        - asset: assets/fonts/proximanova-LightItalic.otf
          weight: 300
          style: italic
        - asset: assets/fonts/proximanova-ExtraLight.otf
          weight: 200
        - asset: assets/fonts/proximanova-ExtraLightItalic.otf
          weight: 200
          style: italic
        - asset: assets/fonts/proximanova-Thin.otf
          weight: 100
        - asset: assets/fonts/proximanova-ThinItalic.otf
          weight: 100
          style: italic



flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/app-icon.png"
  #  min_sdk_android: 21 # android min sdk min:16, default 21
  web:
    generate: true
    image_path: "assets/app-icon.png"
    background_color: "#hexcode"
    theme_color: "#hexcode"
  windows:
    generate: true
    image_path: "assets/app-icon.png"
    icon_size: 48 # min:48, max:256, default: 48

also this is my build script for android release and patch

release

    - &shorebird_build_android_production
        name: Build Android with Shorebird 
        script: |
          shorebird release android \
          --flutter-version=3.24.5 \
          --flavor production \
          --target ./lib/main_prod.dart


    - &shorebird_build_ios_production
        name: Build iOS with Shorebird 
        script: |
          shorebird release ios \
          --flutter-version=3.24.5 \
          --flavor production \
          --target ./lib/main_prod.dart \
          --export-options-plist=/Users/builder/export_options.plist

patch

    - &shorebird_patch_android_production
        name: Android New Patch with Shorebird
        script: | 
          source $CM_ENV
          echo "ANDROID_VERSION:$ANDROID_VERSION"
          echo "IOS_VERSION:$IOS_VERSION"
          shorebird patch android \
          --target lib/main_prod.dart \
          --flavor production \
          --release-version="$ANDROID_VERSION"

    - &shorebird_patch_ios_production
        name: IOS New Patch with Shorebird
        script: | 
          source $CM_ENV
          echo "ANDROID_VERSION:$ANDROID_VERSION"
          echo "IOS_VERSION:$IOS_VERSION"
          shorebird patch ios \
          --target lib/main_prod.dart \
          --flavor production \
          --release-version="$IOS_VERSION" \
          --export-options-plist=/Users/builder/export_options.plist

@eseidel
Copy link
Contributor

eseidel commented Mar 3, 2025

My understanding is that the only check we perform for "native changes" on iOS is checking that the Podfile.lock hash matches. This is because XCode makes other unstable modifications to the binary on each build. (On Android we do something much fancier involving diffing the binaries since Android's clang toolchain produces repeatable/stable builds.)

@eseidel
Copy link
Contributor

eseidel commented Mar 3, 2025

Oh, sorry. This is about android. I see in the original message this involves:

base/dex/classes.dex
base/dex/classes2.dex

@eseidel
Copy link
Contributor

eseidel commented Mar 3, 2025

That typically means that java/kotlin code is changing. Which can be caused by changes to Dart packages if they have a "native" component. Typically checking in pubspec.lock prevents such changes (which shorebird doctor will warn about).

@eseidel
Copy link
Contributor

eseidel commented Mar 3, 2025

I see that you're asserting that these are dart only changes. I wonder if there could be some part of your gradle configuration which is changing the .dex files on every build? One way to test for that would be to run shorebird release android and then immediately shorebird patch android with no code changes.

@eseidel
Copy link
Contributor

eseidel commented Mar 3, 2025

We definitely could/should provide more information when .dex files differ: #2226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for response Waiting for customer response
Projects
None yet
Development

No branches or pull requests

3 participants