Android 3rd party library - interface metadata not visible in NativeScript

Thread is closed for posting
2 posts, 1 answers
  1. Ram
    Ram avatar
    1 posts
    Member since:
    Aug 2014

    Posted 18 Mar 2015 Link to this post


    I have a simple JAR library, trying to use it from NativeScript. I able to instantiate the class, but unable to implement the interface.

    Demo.jar placed in mylib folder
    Next add library to NativeScript project "tns library add android ../mylib"

    NativeScript - javascript code

        // below code not working, app crashes -- Demo.Work interface not visible
        var w = new Demo.Worker();
        w.DoWork("hello", Demo.Work({
                Done: function() { alert('done...'); }

        // below code is working -- passing a java class which implements Demo.Work
        var w = new Demo.Worker();
        var callback = new Demo.WorkImpl();
        w.DoWork("hello", callback);

    ---------------------------- ------------------------------
    package Demo;

    public interface Work {
       public void Done();

    ---------------------------- ------------------------------
    package Demo;

    public class WorkImpl implements Work {
        public void Done() {

    ---------------------------- ------------------------------
    package Demo;

    public class Worker {
        public void DoWork(String message, Work obj) {
            System.out.println("done..." + message);
            obj.Done(); // callback


  2. Answer
    Georgi avatar
    296 posts

    Posted 18 Mar 2015 Link to this post

    Hello Ram,

    You are correct - currently there is no way to extend an existing class or implement an interface coming from a third-party library. The current version of the Android Runtime uses statically generated bindings and the problem is that there are no bindings generated for the external library.

    The good news is we have already implemented a new dynamic binding generator and it is successfully integrated in our development version. We are now thinking how to enable latest development bits as npm packages, so stay tuned, the feature is about to be available very soon.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top