Closed mattbajorek closed 11 months ago
Hi @mattbajorek , the current version of our Flutter SDK wraps our iOS and Android SDKs as native plugins. This sounds like a good place to start the investigation. Have you been able to run our hello-flutter repo?
Can you confirm the presence of the android folder in the Flutter Plugins section of your project? (This is a Flutter project opened in Android Studio).
If these are wrappers are there any specific Android or iOS changes needed? I tried following the Android documents by adding:
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:5.0.0'
to app/build.gradle
and
import com.launchdarkly.sdk.*
import com.launchdarkly.sdk.android.*
to MainActivity.kt
with no avail.
You shouldn't need to make any iOS / Android file changes. I just wanted to confirm the dependency that was fetched does have the native folders.
Have you been able to run our hello-flutter repo?
I am able to run the hello-flutter repo. I found the issue for anyone else is struggling with this. The LDContextBuilder
must have a kind set. By following the example with builder.kind('user', 'user-key-123abc');
the issue went away.
Is there a way to initially not have a kind and then add a kind as user information is provided dynamically?
Ah, I see what happened. We have an existing discrepancy between our Android and iOS SDK where the Android SDK must be provided a non-empty context with a key. We plan to fix the bug Android side when time permits. That error is very cryptic.
I recommend using an anonymous context for the period of time where you have no user information.
https://docs.launchdarkly.com/sdk/features/anonymous#flutter
Thank you for tracking down the cause. I missed that a kind was missing in the original code snippet. Issue has been logged internally as 224717.
@tanderson-ld thank you for the update. I added:
ldContextBuilder.kind('user', 'user-key-123abc').anonymous(true);
The plugin no longer crashes, however when fetching feature flags for example:
var result = await LDClient.boolVariation(featureFlag, true);
The result value is always false even with the default and even though the dashboard is serving true. Any ideas on why this is happening?
Have you turned the targeting for that flag to On? This is a common culprit.
Yes we have it on. We can validate that on the web SDK. We have multiple feature flags and they all come back false for Flutter, but true for web.
Also calling:
final flags = await LDClient.allFlags();
Properly returns all the names of our tags, but all of them are set as false.
I just tested a killSwitch template locally with the Flutter SDK, and it is working on my machine. Do you have any interesting configurations with respect to network permissions, storage permissioning, VPN? Trying to develop a few more theories.
Perhaps the wrong environment key copied/pasted?
Ahh I found it. I was using the prod environment key which was setup but the flags weren't set yet. We can close this.
No worries! We've all been there. If you need other higher level support, you can open a support ticket here. If you run into any more nitty gritty code issues / suspected bugs, feel free to open another issue. Thanks.
@tanderson-ld, I confirm this statement you added once: We have an existing discrepancy between our Android and iOS SDK where the Android SDK must be provided a non-empty context with a key. A non-empty value solves this problem.
Describe the bug
.start
method immediately errors out with MissingPluginException on Android for both simulator and physical device. Is there an extra SDK integration needed?To reproduce
launchdarkly_flutter_client_sdk: ^3.0.1
to pubspec.yamlExpected behavior A clear and concise description of what you expected to happen.
Logs E/flutter (17494): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method start on channel launchdarkly_flutter_client_sdk) E/flutter (17494): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308:7) E/flutter (17494):
E/flutter (17494): #1 LDClient.startWithContext (package:launchdarkly_flutter_client_sdk/launchdarkly_flutter_client_sdk.dart:106:5)
E/flutter (17494):
Flutter version >=3.0.6 <4.0.0
SDK version 4.0.1 and 2.1.0
OS/platform Android