This is a migrated thread and some comments may be shown as answers.

Call Android Class from platform folder

4 Answers 59 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dimitar
Top achievements
Rank 1
Dimitar asked on 18 Sep 2017, 01:01 PM

 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 . 

 

 

4 Answers, 1 is accepted

Sort by
0
Nikolay Tsonev
Telerik team
answered on 18 Sep 2017, 02:48 PM
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.
0
Dimitar
Top achievements
Rank 1
answered on 18 Sep 2017, 03:04 PM

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 . 

0
Dimitar
Top achievements
Rank 1
answered on 18 Sep 2017, 05:57 PM
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.  
0
Nikolay Tsonev
Telerik team
answered on 19 Sep 2017, 05:58 AM
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.
Tags
General Discussion
Asked by
Dimitar
Top achievements
Rank 1
Answers by
Nikolay Tsonev
Telerik team
Dimitar
Top achievements
Rank 1
Share this question
or