#android #flutter #facebook
#android #flutter #facebook
Вопрос:
У меня есть приложение flutter, в котором моя задача-регистрировать события пользователей с помощью событий приложения facebook. Я добавил следующий пакет в свой pubspec.yaml:
facebook_app_events: ^0.14.7
Добавлено следующее в build.gradle:
buildscript { ext.kotlin_version = '1.5.10' repositories { google() jcenter() mavenCentral() //**Added as per fb docs }
Добавлено следующее в app/build.gradle:
dependencies { implementation 'com.facebook.android:facebook-android-sdk:latest.release' }
В AndroidManifest я добавил следующие метаданные:
lt;application ..// lt;meta-data android:name="com.facebook.sdk.ApplicationId" android:value="app id"/gt; lt;/applicationgt;
Позже, в своих представлениях о трепете, я сделал следующую реализацию:
static final facebookSDK = FacebookAppEvents(); TextButton( onPressed: () { facebookSDK.logEvent( name: 'button_clicked', parameters: { 'button_id': 'the_clickme_button', }, ); }, child: Text("Trigger Payment Info Click")),
Когда я нажимаю эту кнопку, я получаю следующую ошибку вместо отправки события входа в fb:
E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): Failed to handle method call E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): kotlin.UninitializedPropertyAccessException: lateinit property appEventsLogger has not been initialized E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at id.oddbit.flutter.facebook_app_events.FacebookAppEventsPlugin.handleLogEvent(FacebookAppEventsPlugin.kt:99) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at id.oddbit.flutter.facebook_app_events.FacebookAppEventsPlugin.onMethodCall(FacebookAppEventsPlugin.kt:48) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at android.os.MessageQueue.next(MessageQueue.java:336) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at android.os.Looper.loop(Looper.java:174) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at android.app.ActivityThread.main(ActivityThread.java:7438) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/MethodChannel#flutter.oddbit.id/facebook_app_events(32475): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:989) E/flutter (32475): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(error, lateinit property appEventsLogger has not been initialized, null, kotlin.UninitializedPropertyAccessException: lateinit property appEventsLogger has not been initialized E/flutter (32475): at id.oddbit.flutter.facebook_app_events.FacebookAppEventsPlugin.handleLogEvent(FacebookAppEventsPlugin.kt:99) E/flutter (32475): at id.oddbit.flutter.facebook_app_events.FacebookAppEventsPlugin.onMethodCall(FacebookAppEventsPlugin.kt:48) E/flutter (32475): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) E/flutter (32475): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84) E/flutter (32475): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865) E/flutter (32475): at android.os.MessageQueue.nativePollOnce(Native Method) E/flutter (32475): at android.os.MessageQueue.next(MessageQueue.java:336) E/flutter (32475): at android.os.Looper.loop(Looper.java:174) E/flutter (32475): at android.app.ActivityThread.main(ActivityThread.java:7438) E/flutter (32475): at java.lang.reflect.Method.invoke(Native Method) E/flutter (32475): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/flutter (32475): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:989) E/flutter (32475): ) E/flutter (32475): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7) E/flutter (32475): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18) E/flutter (32475): lt;asynchronous suspensiongt;
I deleted .gradle folder, ran flutter clean still no help. I do not know much about native kotlin. Any sort of help will be appreciated.