icapps / flutter-background-location-tracker

Flutter background location tracker plugin. (Android / iOS)
MIT License
31 stars 37 forks source link

java.lang.IncompatibleClassChangeError - package stopped working all of the sudden #50

Closed steffomix closed 1 year ago

steffomix commented 1 year ago

I Isolated this git package to run alone on android api level 33. The same result with the package from pub.

environment: sdk: '>=2.19.4 <3.0.0'

dependencies: flutter: sdk: flutter

background_location_tracker: ^1.4.0

background_location_tracker: git: url: https://github.com/icapps/flutter-background-location-tracker.git ref: master

Thats all, a new empty project. All worked fine until maybe two weeks ago or so. I tried it on a phyiscal phone as well as an emulator but the result is the same.

Launching lib\main.dart on SM A336B in debug mode... √ Built build\app\outputs\flutter-apk\app-debug.apk. E/AndroidRuntime(28852): FATAL EXCEPTION: main E/AndroidRuntime(28852): Process: com.example.test, PID: 28852 E/AndroidRuntime(28852): java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~pUcg6T2zI8_sLL0_yHxi0g==/com.example.test-cg1nqPCv-F6eh9i2IxbN4Q==/base.apk) E/AndroidRuntime(28852): at com.icapps.background_location_tracker.service.LocationUpdatesService.getLastLocation(LocationUpdatesService.kt:215) E/AndroidRuntime(28852): at com.icapps.background_location_tracker.service.LocationUpdatesService.onCreate(LocationUpdatesService.kt:74) E/AndroidRuntime(28852): at android.app.ActivityThread.handleCreateService(ActivityThread.java:5060) E/AndroidRuntime(28852): at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0) E/AndroidRuntime(28852): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2425) E/AndroidRuntime(28852): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(28852): at android.os.Looper.loopOnce(Looper.java:226) E/AndroidRuntime(28852): at android.os.Looper.loop(Looper.java:313) E/AndroidRuntime(28852): at android.app.ActivityThread.main(ActivityThread.java:8741) E/AndroidRuntime(28852): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(28852): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) E/AndroidRuntime(28852): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Exited (1)

steffomix commented 1 year ago

So far, running the package example directly works like a charme but the moment I import it into a new flutter project it doesn't.

steffomix commented 1 year ago

Finally I was able to create a workaround.

Example of importing a package as file:

dependencies:
  flutter:
    sdk: flutter

  # https://github.com/icapps/flutter-background-location-tracker
  background_location_tracker:
    path: ../git-packages/flutter-background-location-tracker

Avoid using package geolocator together with flutter-background-location-tracker and replace it with package location.

ikbendewilliam commented 1 year ago

This should be fixed now, thank you for your issue + PR