Skip to content

Add Keep annotations to kotlin plugin example #640

Closed
dart-archive/jnigen
#296

Description

@mahesh-hegde

It crashes in release mode.

E/flutter (32388): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception in Java code called through JNI: java.lang.NoSuchMethodError: no non-static method "LExample;.thinkBeforeAnswering(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"
E/flutter (32388):
E/flutter (32388): java.lang.NoSuchMethodError: no non-static method "LExample;.thinkBeforeAnswering(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;"
E/flutter (32388):
E/flutter (32388):
E/flutter (32388): #0      JniAccessorWrappers.throwException (package:jni/src/accessors.dart:116)
E/flutter (32388): dart-lang/jnigen#1      _check (package:jni/src/accessors.dart:16)
E/flutter (32388): dart-lang/jnigen#2      JniResultMethods.check (package:jni/src/accessors.dart:21)
E/flutter (32388): dart-lang/jnigen#3      JniResultMethods.object (package:jni/src/accessors.dart:59)
E/flutter (32388): dart-lang/jnigen#4      Example.thinkBeforeAnswering (package:kotlin_plugin/kotlin_bindings.dart:61)
<Redacted>

Activity

  1. mahesh-hegde commented on Apr 30, 2023

    @mahesh-hegde
    ContributorAuthor

    Edit: It has Keep but for some reason it's not being applied to the continuation. I am not completely familiar with the suspend fn implementation.

  2. mahesh-hegde commented on Apr 30, 2023

    @mahesh-hegde
    ContributorAuthor

    It requires -dontobfuscate flag in proguard rules, because proguard obfuscates private method names.

    Realized when google search returned this question https://stackoverflow.com/questions/9651703/using-proguard-with-android-without-obfuscation.

  3. HosseinYousefi commented on Jun 1, 2023

    @HosseinYousefi
    Contributor

    Is this fixed now?

  4. mahesh-hegde commented on Jun 1, 2023

    @mahesh-hegde
    ContributorAuthor

    Nope I didn't do any code changes regarding this. You might try, and check if adding -dontobfuscate works. It worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions