bkonyi / FlutterGeofencing

Rough work for Flutter geofencing plugin
BSD 3-Clause "New" or "Revised" License
337 stars 219 forks source link

sPluginRegistrantCallback has not been initialized #46

Closed niypoo closed 3 years ago

niypoo commented 4 years ago

I have created new project in android embedding 2 with package example and I have facing this issue when tap on register btn

/AndroidRuntime( 8624): Process: com.example.ggofence, PID: 8624
E/AndroidRuntime( 8624): java.lang.RuntimeException: Unable to create service io.flutter.plugins.geofencing.GeofencingService: kotlin.UninitializedPropertyAccessException: lateinit property sPluginRegistrantCallback has not been initialized
E/AndroidRuntime( 8624):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3965)
E/AndroidRuntime( 8624):    at android.app.ActivityThread.access$1500(ActivityThread.java:219)
E/AndroidRuntime( 8624):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875)
E/AndroidRuntime( 8624):    at android.app.ActivityThread.access$1500(ActivityThread.java:219)
E/AndroidRuntime( 8624):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875)
E/AndroidRuntime( 8624):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 8624):    at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 8624):    at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime( 8624):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8624):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 8624):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/AndroidRuntime( 8624): Caused by: kotlin.UninitializedPropertyAccessException: lateinit property sPluginRegistrantCallback has not been initialized
E/AndroidRuntime( 8624):    at io.flutter.plugins.geofencing.GeofencingService.startGeofencingService(GeofencingService.kt:74)
E/AndroidRuntime( 8624):    at io.flutter.plugins.geofencing.GeofencingService.onCreate(GeofencingService.kt:114)
E/AndroidRuntime( 8624):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)
E/AndroidRuntime( 8624):    ... 8 more
I/Process ( 8624): Sending signal. PID: 8624 SIG: 9
devUsama commented 4 years ago

facing the same issue! found any solution?

devUsama commented 4 years ago

Solved it! sPluginRegistrantCallback variable was accessing before initialization, lateinit variable must be initialized before accessing it in kotlin. So, you can check if these variables are initialized before accessing in GeofencingService.kt file in main project. Also created a pull request you can wait if it get merge., till then you can apply this patch.

patch.diff.zip

iolk commented 4 years ago

Same issue but the patch worked very well, thanks!

jjakob666 commented 4 years ago

Thanks fixed for me too