Я пытаюсь использовать пакет geofencing в своем приложении Flutter. Я установил его и выполнил всю настройку для обработки разрешений и регистрации фоновой службы. Вот мой файл манифеста:
<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>
Теперь в документации пакета написано, что мне нужно создать класс Application в той же папке, что и MainActiviy, и указать его в файле манифеста, что я и делаю. Ниже мой файл Appliction.kt:
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);
}
}
Когда я пытаюсь собрать проект, я получаю следующее исключение:
Примечание. Некоторые входные файлы используют или переопределяют устаревший API.
Примечание. Для получения подробной информации перекомпилируйте с помощью -Xlint: deprecation.
e: / home / user / flutter projects / geofencing_flutter / android / app / src / main /kotlin/com/example/geofencing/Application.kt: (13, 48): Несоответствие типов: предполагаемый тип - PluginRegistry, но ожидалось FlutterEngine
Как я могу решить эту проблему?