flutter-unity-view-widget icon indicating copy to clipboard operation
flutter-unity-view-widget copied to clipboard

[Android] Compiling error flutter 3.24

Open lorisgir opened this issue 1 year ago • 7 comments

Describe the bug After the update to flutter 3.24 every time I try to build & run on the emulator I get these error messages: e: file:///Users/{user}/.pub-cache/hosted/pub.dev/flutter_unity_widget-2022.2.1/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityWidgetPlugin.kt:97:9 Cannot weaken access privilege 'public' for 'lifecycle' in 'LifecycleOwner' e: file:///Users/{user}/.pub-cache/hosted/pub.dev/flutter_unity_widget-2022.2.1/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityWidgetPlugin.kt:97:21 'lifecycle' hides member of supertype 'LifecycleOwner' and needs 'override' modifier

I already tried to run flutter clean and rebuild the unity project from unity but always the same error

Unity:

  • OS: MacOS
  • Version 2022.3.36

Smartphone:

  • Device: Pixel 8 Emulator
  • OS: Android
  • Version 15

lorisgir avatar Aug 08 '24 10:08 lorisgir

Looks like an AndroidX library got updated in Flutter, resulting in an change in the LifecycleOwner kotlin interface.

As a result the current implementation breaks on Flutter 3.24.0+, but updating this implementation will break the plugin on all earlier Flutter versions.

Looking at the source, this is only used in a private class, which does not seem to have any references anywhere else in the plugin. I also added a log in each function, but I never saw any output in logcat. So it looks like this class isn't even used. https://github.com/juicycleff/flutter-unity-view-widget/blob/45fffb52e5e2c101bda435e396218b2ad9c56503/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityWidgetPlugin.kt#L96-L163

Simply deleting or commenting this class does not seem to break anything and allows me to run the example project with Flutter 3.24.

[UPDATE] Looks like the reference using the class was removed over 2 years ago in https://github.com/juicycleff/flutter-unity-view-widget/commit/e4cd05930a5dc7f0b4b9c8457061020e2d24a3fa

[UPDATE 2] The fix below is now also on the master branch.

As a test I made a branch that should get this working again.

You can try it using this in pubspec.yaml:

flutter_unity_widget:
    git:
      url: https://github.com/juicycleff/flutter-unity-view-widget.git
      ref: master # branch name or commit hash
      # UPDATE: this fix is now included in the master branch
      # ref: flutter_3.24_android_hotfix

I can't publish plugin updates, so we would need @juicycleff to make a new release for Flutter 3.24.

timbotimbo avatar Aug 09 '24 16:08 timbotimbo

@timbotimbo Thank you very much! You helped me a lot! God bless you!

viktorsht avatar Aug 13 '24 13:08 viktorsht

@timbotimbo Any chance you could apply that same fix over on the 6.0 branch? I'm testing it out and just hit this error, and one other one I'm about to write up.

artificerchris avatar Aug 15 '24 20:08 artificerchris

I added the fix to the master branch, to make sure it gets included in a future update. This issue can stay open until it reaches pub.dev.

@artificerchris I've merged the updated master into the 6000 branch as well.

timbotimbo avatar Aug 15 '24 23:08 timbotimbo

Thank you very much!

artificerchris avatar Aug 15 '24 23:08 artificerchris

thanks you it is working now

keyss-vivaan avatar Oct 09 '24 12:10 keyss-vivaan

Looks like an AndroidX library got updated in Flutter, resulting in an change in the LifecycleOwner kotlin interface.

As a result the current implementation breaks on Flutter 3.24.0+, but updating this implementation will break the plugin on all earlier Flutter versions.

Looking at the source, this is only used in a private class, which does not seem to have any references anywhere else in the plugin. I also added a log in each function, but I never saw any output in logcat. So it looks like this class isn't even used.

https://github.com/juicycleff/flutter-unity-view-widget/blob/45fffb52e5e2c101bda435e396218b2ad9c56503/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityWidgetPlugin.kt#L96-L163

Simply deleting or commenting this class does not seem to break anything and allows me to run the example project with Flutter 3.24.

[UPDATE] Looks like the reference using the class was removed over 2 years ago in e4cd059

[UPDATE 2] The fix below is now also on the master branch.

As a test I made a branch that should get this working again.

You can try it using this in pubspec.yaml:

flutter_unity_widget:
    git:
      url: https://github.com/juicycleff/flutter-unity-view-widget.git
      ref: flutter_3.24_android_hotfix # branch name
      # UPDATE: this fix is now included in the master branch

I can't publish plugin updates, so we would need @juicycleff to make a new release for Flutter 3.24.

this fixed most of my problems, I later had some conflicts with NDK but I managed to fix it. Thank you

guilherme-francisco avatar Oct 13 '24 02:10 guilherme-francisco