Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for abstract interface with static methods #1157

Closed
vtrifonov opened this issue Aug 13, 2018 · 1 comment
Closed

Support for abstract interface with static methods #1157

vtrifonov opened this issue Aug 13, 2018 · 1 comment
Assignees
Milestone

Comments

@vtrifonov
Copy link
Contributor

vtrifonov commented Aug 13, 2018

Currently the android runtime does not support calls to static methods which are implemented in abstract interfaces e.g.:

package com.tns.tests;

public abstract interface AbstractInterface {

    public static int test()
    {
        return 1;
    }
}

A call like this:

var test = com.tns.tests.AbstractInterface.test();

will result in:

Error: java.lang.NoSuchMethodError: no static method "Lcom/tns/tests/AbstractInterface;.test()I"
    com.tns.Runtime.callJSMethodNative(Native Method)
    com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
    com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
    com.tns.Runtime.callJSMethod(Runtime.java:983)
    com.tns.Runtime.callJSMethod(Runtime.java:967)
    com.tns.Runtime.callJSMethod(Runtime.java:959)
    com.tns.gen.android.view.View_OnClickListener.onClick(View_OnClickListener.java:16)
    android.view.View.performClick(View.java:5637)
    android.view.View$PerformClick.run(View.java:22429)
    android.os.Handler.handleCallback(Handler.java:751)
    android.os.Handler.dispatchMessage(Handler.java:95)
    android.os.Looper.loop(Looper.java:154)
    android.app.ActivityThread.main(ActivityThread.java:6119)
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Using Google WebRTC causes this error:

dependencies {
    implementation 'org.webrtc:google-webrtc:1.0.+'
}
@vtrifonov
Copy link
Contributor Author

vtrifonov commented Aug 13, 2018

Seems like setting minSdkVersion to 24 fixes the issue:

android {
  ....
  defaultConfig {
    minSdkVersion 24
    ....
  }
}

. This is actually because the static interface method requires API level 24, although it is stated in this article that any API level is compatible when using Java 1.8, but however JNI calls to such methods are not working with API level < 24.
screen shot 2018-08-13 at 20 42 38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants