Innim / flutter_login_vk

Flutter Plugin to login via VK.com
BSD 3-Clause "New" or "Revised" License
18 stars 17 forks source link

vk login works on debug, build but does not work on release build #25

Closed gadgetreviews closed 1 year ago

gadgetreviews commented 2 years ago

I have a problem. When I run in debug mode with emulator, vk login works fine. But when I build a release build apk and run it on a real device I get following error at this code. res.isError is false and res.isValue is false: And error message instantly happens, there is no delay. I guess it does not communicate with vk servers.

    final vk = VKLogin();
    await vk.initSdk();
    final res = await vk.logIn(scope: [
      VKScope.email,
      VKScope.photos,
      VKScope.offline,
      VKScope.friends,
    ]);
    if (res.isError) {
... does not reach here
    }
    if (res.isValue) {
... does not reach here
    } else {
// reach here
      var error = res.asError;
      var str = error!.error.toString();
      FlutterClipboard.copy(str).then((value) {});
    }
PlatformException(error, No enum constant com.vk.api.sdk.auth.VKScope.EMAİL, null, java.lang.IllegalArgumentException: No enum constant com.vk.api.sdk.auth.VKScope.EMAİL
    at java.lang.Enum.valueOf(Enum.java:258)
    at com.vk.api.sdk.auth.VKScope.valueOf(Unknown Source:2)
    at o.a.b.e.e(Unknown Source:43)
    at o.a.b.e.i(Unknown Source:28)
    at o.a.b.e.onMethodCall(Unknown Source:85)
    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(Unknown Source:17)
    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(Unknown Source:18)
    at io.flutter.embedding.engine.dart.DartMessenger.a(Unknown Source:20)
    at io.flutter.embedding.engine.dart.DartMessenger.b(Unknown Source:0)
    at io.flutter.embedding.engine.dart.c.run(Unknown Source:12)
    at android.os.Handler.handleCallback(Unknown Source:2)
    at android.os.Handler.dispatchMessage(Unknown Source:4)
    at android.os.Looper.loop(Unknown Source:207)
    at android.app.ActivityThread.main(Unknown Source:107)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
    at com.android.internal.os.ZygoteInit.main(Unknown Source:274)
)
gadgetreviews commented 2 years ago

I found that this problem occurs when device's language is Turkish. Maybe another language would effect. I tested with English and French. There was no problem with English and French. But I didn't test it with other languages.

The problem was with No enum constant com.vk.api.sdk.auth.VKScope.EMAİL Is should be No enum constant com.vk.api.sdk.auth.VKScope.EMAIL or No enum constant com.vk.api.sdk.auth.VKScope.email. But when language was Turkish EMAIL transform to EMAİL. And this causes exception. Any idea how to solve this?

Thanks

gadgetreviews commented 2 years ago

does EMAIL at com.vk.api.sdk.auth.VKScope.EMAIL have to be uppercase?

There are 2 different i and I letters in Turkish. One with dot and one without dot. And this causes problem when transposing uppercase:

In Turkish: lower case i's capital is İ (with dot) lower case ı's capital is I (without dot)

English rule uppercase function should be used when converting email to uppercase.

gadgetreviews commented 2 years ago

in MethodCallHandler.kt file

            val scope = VKScope.valueOf(item.uppercase(Locale.getDefault()))

uppercase function takes Locale.getDefault() parameter. I don't know kotlin good enough. But is it possible to call this uppercase without locale or with English locale?

gadgetreviews commented 2 years ago

I removed Locale.getDefault() parameter and it worked. I created a PR.

https://github.com/Innim/flutter_login_vk/pull/26

greymag commented 1 year ago

Thanks for the issue! Fixes in 2.2.2