background_location icon indicating copy to clipboard operation
background_location copied to clipboard

Bug: Flutter 3.29 Breaking Changes

Open zwells opened this issue 10 months ago • 19 comments

Description

https://benamorn.medium.com/today-i-learned-after-upgrading-to-flutter-3-29-0-7c7ab1a97975

Steps to Reproduce

Upgrade to Flutter 3.29

Expected Behavior

Successful Compile

Actual Behavior

e: background_location/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationPlugin.kt:20:50 Unresolved reference 'context'.
e: background_location/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationPlugin.kt:20:71 Unresolved reference 'messenger'.
e: background_location/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationPlugin.kt:21:23 Unresolved reference 'addRequestPermissionsResultListener'.```

zwells avatar Feb 17 '25 19:02 zwells

Does #240 fix this issue for you?

MoralCode avatar Feb 18 '25 13:02 MoralCode

#240 flutter 3.29.0 error message:

git/background_location-c9ec16ed439443beea6b08e18c1e1869ffc7190a/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:255:19 Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The actual metadata version is 2.1.0, but the compiler version 1.8.0 can read versions up to 1.9.0.

There's a lot of the same, not just one

davidche1116 avatar Feb 19 '25 03:02 davidche1116

I'm not sure quite how to read that error. is that saying this package was compiled with newer kotlin than your machine? or the other way around?

MoralCode avatar Feb 19 '25 14:02 MoralCode

Does #240 fix this issue for you?

same issue here... how can i test with that PR before merge? i'm not sure

emanuelerighetto avatar Feb 20 '25 00:02 emanuelerighetto

This issue is caused by the deprecation of io.flutter.plugin.common.PluginRegistry.Registrar. Modifying the deprecated code should resolve the problem. Regarding #240, simply change ext.kotlin_version to = '1.8.22' and version 3.29.0 should compile successfully to solve the compilation errors.

davidche1116 avatar Feb 20 '25 07:02 davidche1116

Facing the same issue here:

/background_location/BackgroundLocationPlugin.kt:18:52 Unresolved reference: Registrar

thicorrea1 avatar Feb 21 '25 18:02 thicorrea1

This issue is caused by the deprecation of io.flutter.plugin.common.PluginRegistry.Registrar. Modifying the deprecated code should resolve the problem. Regarding #240, simply change ext.kotlin_version to = '1.8.22' and version 3.29.0 should compile successfully to solve the compilation errors.

Seems like the deprecation warning was intentionally suppressed too https://github.com/Almoullim/background_location/blob/d7acf43253a40a142540cb28c5ee5b0d27317c09/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationPlugin.kt#L17

Googling around seems like the solution for this is

We had to manually pull those dependencies, remove this import, and modify some code related to PluginRegistry.Registrar.

Which sounds like more work than migrating to some other suggested thing

I don't have the bandwidth to implement this but can merge an MR containing it if others can propose a fix and help with testing to confirm that it works

MoralCode avatar Feb 22 '25 02:02 MoralCode

I've tryed updating my dependency using the quote PR:

  background_location:
    git:
      url: https://github.com/zaave/background_location/
      ref: fix-flutter-3.30-build

And i confirm that for me the solutions is working

emanuelerighetto avatar Feb 23 '25 20:02 emanuelerighetto

We had to manually pull those dependencies, remove this import, and modify some code related to PluginRegistry.Registrar.

Which sounds like more work than migrating to some other suggested thing

That's correct. For #240, Only removed the lines containing the @SuppressWarnings("deprecation") annotation and the deprecated function. No other modifications are actually required. It works with version 3.29.0 as long as you delete that deprecated interface.

davidche1116 avatar Feb 24 '25 05:02 davidche1116

Only removed the lines containing the @SuppressWarnings("deprecation") annotation and the deprecated function.

what functionality depends on that function though. Shouldn't the deprecated function be replaced with a non-deprecated alternative?

MoralCode avatar Feb 24 '25 15:02 MoralCode

I've tryed updating my dependency using the quote PR:

  background_location:
    git:
      url: https://github.com/zaave/background_location/
      ref: fix-flutter-3.30-build

And i confirm that for me the solutions is working

This worked for me, but try to solve the problem and merge it.

adarshtiwariiit avatar Mar 17 '25 10:03 adarshtiwariiit

I've tryed updating my dependency using the quote PR:

  background_location:
    git:
      url: https://github.com/zaave/background_location/
      ref: fix-flutter-3.30-build

And i confirm that for me the solutions is working

This worked for me, but try to solve the problem and merge it.

Sadly this did not work for me

jrmerril avatar Mar 24 '25 12:03 jrmerril

Same issue.

Also this did not work for me as well: background_location: git: url: https://github.com/zaave/background_location/ ref: fix-flutter-3.30-build

stanimeros avatar Mar 28 '25 15:03 stanimeros

for those saying it did not work, are there other errors occurring? what version of flutter are you using?

MoralCode avatar Mar 28 '25 19:03 MoralCode

Flutter 3.29.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision c236373904 (2 weeks ago) • 2025-03-13 16:17:06 -0400 Engine • revision 18b71d647a Tools • Dart 3.7.2 • DevTools 2.42.3

When building in android I am getting:

Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors e: file:///Users/stanimeros/.gradle/caches/8.10.2/transforms/a60c4095f76a35cfd35e0bda2ec2182b/transformed/jetified-kotlin-stdlib-2.1.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0. ....

Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 3 warnings

  • What went wrong: Execution failed for task ':background_location:compileReleaseKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction Compilation error. See log for more details

stanimeros avatar Mar 28 '25 19:03 stanimeros

@MoralCode Have you find any solution? Or do you have any idea how to solve this?

stanimeros avatar Mar 29 '25 13:03 stanimeros

No, I havent had time to investigate in any detail and likely won't for a while

The error you posted seems to refer to another log file. Does that file contain any additional information on the errors? Or is its content the same as what you posted?

MoralCode avatar Mar 29 '25 15:03 MoralCode

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 29 '25 10:04 github-actions[bot]

Same issue with 3.32.5, please fix it. thanks!

dipakravalVH avatar Jul 22 '25 07:07 dipakravalVH