1

I am trying to use geofencing package in my flutter application. I have installed it and did all the config to handle permission and register a background service. Here is my manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.geofencing">
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />


  <application android:name=".Application" android:label="geofencing" android:icon="@mipmap/ic_launcher">
    <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
 
      <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />

      <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data android:name="flutterEmbedding" android:value="2" />

    <receiver android:name="io.flutter.plugins.geofencing.GeofencingBroadcastReceiver" android:enabled="true" android:exported="true" />
    <service android:name="io.flutter.plugins.geofencing.GeofencingService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" />
  </application>
</manifest>

Now in the documentation of package it's written that I need to create an Application class in the same folder as MainActiviy and reference it in manifest file which is exactly what I am doing. Below is my Appliction.kt file:

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugins.geofencing.GeofencingService

class MyApp : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate();
        GeofencingService.setPluginRegistrant(this)
    }

    override fun registerWith(registry: PluginRegistry) {
        GeneratedPluginRegistrant.registerWith(registry);
    }
}

When I try to build the project I get this exception:

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
e: /home/user/flutter projects/geofencing_flutter/android/app/src/main/kotlin/com/example/geofencing/Application.kt: (13, 48): Type mismatch: inferred type is PluginRegistry but FlutterEngine was expected

How can I solve this problem?

Mateen Kiani
  • 2,869
  • 2
  • 19
  • 29
  • Do you have an update on this? I'm facing the same issue. – Diego Ramírez Feb 03 '21 at 03:23
  • https://stackoverflow.com/questions/59437284/type-mismatch-inferred-type-is-pluginregistry-but-flutterengine-was-expected this might help. I was using geofencing plugin which in the documentation says to add myApplication.kt but in their own example they didn't add this plugin registration code. Also they updated the plugin to v2 so I think this step wasn't required as plugins are automatically registered since there is a Java file that is generated by system to register plugins. This is what I think you may correct me if I am wrong. – Mateen Kiani Feb 03 '21 at 08:45

0 Answers0