rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 328 forks source link

Unresolved reference #234

Open ludesert opened 3 years ago

ludesert commented 3 years ago

Whenever I try to compile a new version of my app, I get this error :

e: D:...\myapp\Application.kt: (11, 21): Unresolved reference: googleapiavailability e: D:...\myapp\Application.kt: (18, 30): Unresolved reference: setPluginRegistrant e: D:...\myapp\Application.kt: (33, 13): Unresolved reference: GoogleApiAvailabilityPlugin

I did not change the Application.kt file. Everything worked well before and I can't figure out what happened. What I did :

Note : I tried downgrading dependencies and removing the small changes I made in my app and only got this error :

e: D:...\myapp\Application.kt: (18, 30): Unresolved reference: setPluginRegistrant

Here is my Application.kt file :

`package com.ludesert.myapp

import io.flutter.app.FlutterApplication import io.flutter.plugin.common.PluginRegistry import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback import io.flutter.view.FlutterMain import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin import rekab.app.background_locator.IsolateHolderService import com.baseflow.geolocator.GeolocatorPlugin import com.baseflow.location_permissions.LocationPermissionsPlugin import com.baseflow.googleapiavailability.GoogleApiAvailabilityPlugin import com.tekartik.sqflite.SqflitePlugin

class Application : FlutterApplication(), PluginRegistrantCallback { override fun onCreate() { super.onCreate() IsolateHolderService.setPluginRegistrant(this) FlutterMain.startInitialization(this) }

override fun registerWith(registry: PluginRegistry?) {
    if (!registry!!.hasPlugin("io.flutter.plugins.shared_preferences")) {
        SharedPreferencesPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.shared_preferences"))
    }
    if (!registry!!.hasPlugin("com.baseflow.geolocator")) {
        GeolocatorPlugin.registerWith(registry!!.registrarFor("com.baseflow.geolocator"))
    }
    if (!registry!!.hasPlugin("com.baseflow.location_permissions")) {
        LocationPermissionsPlugin.registerWith(registry!!.registrarFor("com.baseflow.location_permissions"))
    }
    if (!registry!!.hasPlugin("com.baseflow.google_api_availability")) {
        GoogleApiAvailabilityPlugin.registerWith(registry!!.registrarFor("com.baseflow.google_api_availability"))
    }
    if (!registry!!.hasPlugin("com.tekartik.sqflite")) {
        SqflitePlugin.registerWith(registry!!.registrarFor("com.tekartik.sqflite"))
    }
}

} `

SandeMK commented 3 years ago

For the Flutter Android Embedding V2, plugins are registered with the background isolate via reflection so IsolateHolderService.setPluginRegistrant does not need to be called. I'm using SharedPreferences and FirebaseFirestore and it's working all fine.

ludesert commented 3 years ago

So with Flutter V2, I don't have to register the plugins manually via Application.kt, thus I don't need it anymore ?

ludesert commented 3 years ago

For the Flutter Android Embedding V2, plugins are registered with the background isolate via reflection so IsolateHolderService.setPluginRegistrant does not need to be called. I'm using SharedPreferences and FirebaseFirestore and it's working all fine.

How should the plugins be registered with flutter V2 ? The wiki does not seem to be up to date considering what you say and I'm not sure how to do. Thanks

ludesert commented 3 years ago

no-one ?

steinmetz commented 3 years ago

@ludesert I removed this line IsolateHolderService.setPluginRegistrant since the method setPluginRegistrant is not existing anymore. So far, everything is working fine ( I am using it with pathprovider) I think this wiki is not updated

@mehdok can you please confirm if IsolateHolderService.setPluginRegistrant should not be used? Thank you!