Call Android Class from platform folder

5 posts, 0 answers
  1. Dimitar
    Dimitar avatar
    45 posts
    Member since:
    May 2014

    Posted 18 Sep Link to this post

     Hello,
        I have added Utils2.java file in C:\tns\MyApp\platforms\android\src\main\java\com\myApphelp
    And after that I am trying to call a static method , but I received an error "Can not read property Utils2 of undefined file: ....getures.js" 
    com.chatcardhelp.Utils2.determineNoiseAround(mgr,  callbackFunc);

    Some idea , what I am missing . 

     

     

  2. nikolay.tsonev
    Admin
    nikolay.tsonev avatar
    287 posts

    Posted 18 Sep Link to this post

    Hi Dimitar,

    Could you provide some more info about your case and the need the need to add java file directly in the platforms folder? It would also help if you provide info, what is the expected final result.

    In the meantime, In case you need to expose some native class, I would suggest creating your own NaiiveScript plugin, which exposes the needed native methods and classes. For your help, you could review this article here and as a starting point, you could use nativescript-plugin-seed.

    Regards,
    nikolay.tsonev
    Progress Telerik
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
  3. Dimitar
    Dimitar avatar
    45 posts
    Member since:
    May 2014

    Posted 18 Sep in reply to nikolay.tsonev Link to this post

    Hi Nikolai ,

    In general I needed to detect a noise environment , so the easier way is to call a java class which I have already have and just pass the result to the nativescript. But do I missing something. Because I though I could call directly the java classes using the full package name .  For regrets it's too late  for using using nativescript-plugin-seed . 

  4. Dimitar
    Dimitar avatar
    45 posts
    Member since:
    May 2014

    Posted 18 Sep Link to this post

    Hi I think I have fixed the issue. Not sure , but how I could force to rebuild the project with this files added in the plarform folder. Because it seems in some moment it was rebuild the full project and then start working.  
  5. nikolay.tsonev
    Admin
    nikolay.tsonev avatar
    287 posts

    Posted 19 Sep Link to this post

    Hi Dimitar,

    I could suggest using --syncAllFile flag, which will detect all changes in the project and will sync the files and will copy them on the device or simulator, where the project is built.For example:
    tns run android --syncAllFiles

    Hope this will help.

    Regards,
    nikolay.tsonev
    Progress Telerik
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
Back to Top