WebEngage / webengage-flutter

WebEngage Flutter Plugin
Apache License 2.0
4 stars 21 forks source link

MissingPluginException #24

Closed rahulraorefyne closed 1 year ago

rahulraorefyne commented 2 years ago

MissingPluginException(No implementation found for method trackEvent on channel webengage_flutter)

WebEngage throws this exception:

MissingPluginException: MissingPluginException(No implementation found for method trackEvent on channel webengage_flutter) File "platform_channel.dart", line 165, in MethodChannel._invokeMethod File "" File "webengage_flutter.dart", line 153, in WebEngagePlugin.trackEvent File ""

MilindWebEngage commented 1 year ago

@rahulraorefyne Can you tell which WebEngage_flutter version you are using and on which platform (iOS or Android) you are getting this error. our latest plugin is 1.2.0

mahanabd commented 1 year ago

yes its true we mack MainApplication class like this:

`import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterFragmentActivity

import com.webengage.sdk.android.WebEngageActivityLifeCycleCallbacks; import io.flutter.app.FlutterApplication; import com.webengage.webengage_plugin.WebengageInitializer; import com.webengage.sdk.android.WebEngageConfig; import com.webengage.sdk.android.WebEngage; import com.webengage.sdk.android.WebEngageActivityLifeCycleCallbacks; import com.webengage.sdk.android.LocationTrackingStrategy;

class MainApplication : FlutterApplication() { fun onCreate() { super.onCreate() val webEngageConfig = WebEngageConfig.Builder() .setWebEngageKey("~key") .setAutoGCMRegistrationFlag(false) .setLocationTrackingStrategy(LocationTrackingStrategy.ACCURACY_BEST) .setDebugMode(true) // only in development mode .build() WebengageInitializer.initialize(this, webEngageConfig) } }`

and get this errors:

`e: /Users/mahanabedini/AndroidStudioProjects/doki-app-new26/android/app/src/main/kotlin/es/mhholding/doki_app/MainApplication.kt: (6, 34): Conflicting import, imported name 'WebEngageActivityLifeCycleCallbacks' is ambiguous e: /Users/mahanabedini/AndroidStudioProjects/doki-app-new26/android/app/src/main/kotlin/es/mhholding/doki_app/MainApplication.kt: (11, 34): Conflicting import, imported name 'WebEngageActivityLifeCycleCallbacks' is ambiguous e: /Users/mahanabedini/AndroidStudioProjects/doki-app-new26/android/app/src/main/kotlin/es/mhholding/doki_app/MainApplication.kt: (15, 9): 'onCreate' hides member of supertype 'FlutterApplication' and needs 'override' modifier

FAILURE: Build failed with an exception.

BUILD FAILED in 16s Exception: Gradle task assembleDebug failed with exit code 1`

i used like document: https://docs.webengage.com/docs/flutter

MilindWebEngage commented 1 year ago

@mahanabd As per the log , there were multiple import of same file - WebEngageActivityLifeCycleCallbacks. just remove the one import line 9 and add a override annotation before fun onCreate()

import com.webengage.sdk.android.WebEngageActivityLifeCycleCallbacks;

the above code will look like the below one

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity

import io.flutter.app.FlutterApplication;
import com.webengage.webengage_plugin.WebengageInitializer;
import com.webengage.sdk.android.WebEngageConfig;
import com.webengage.sdk.android.WebEngage;
import com.webengage.sdk.android.WebEngageActivityLifeCycleCallbacks;
import com.webengage.sdk.android.LocationTrackingStrategy;

class MainApplication : FlutterApplication() {
    override fun onCreate() {
        super.onCreate()
        val webEngageConfig = WebEngageConfig.Builder()
            .setWebEngageKey("YOUR_LICENCSE_CODE")
            .setAutoGCMRegistrationFlag(false)
            .setLocationTrackingStrategy(LocationTrackingStrategy.ACCURACY_BEST)
            .setDebugMode(true) // only in development mode
            .build()
        WebengageInitializer.initialize(this, webEngageConfig)
    }
}

We will also update our docs for the same . If you have any queries then you can reach out to us on support@webengage.com.

mahanabd commented 1 year ago

@MilindWebEngage oh sorry for this issue