0

I already create an .aar (android library) files in android studio and want to call/use it in nativescript-vue project.

I have placed the aar file in "app/App_Resources/Android/libs" folder.

Based on my reading, in typescript the way to call the method in aar files is by calling com.package.MyClass.

My question is , how to call it in .vue files. I have tried to call the method using the same approach but its produce an error :

Module not found: Error: Can't resolve com.package.MyClass

Can someone please help me on this.

Your help is very much appreciated.

1
  • I'm manage to solve this issue. I need to create a constructor in MyClass classes. in my vue : var y = new com.package.MyClass(); console.log('test-->' + y.methodName()); Commented Apr 11, 2019 at 10:00

2 Answers 2

2

You may simply place your AAR file in your App_Resources/Android/libs directory, CLI will pick it up at build time and the native APIs should be available at runtime within your project.

Try a clean build if you see errors, make sure the AAR is picked up. You might be able to verify it from the CLI logs. If you still see issues, make sure the class you are trying to access is public.

Sign up to request clarification or add additional context in comments.

Comments

1

I'm not sure it's possible to use the android lib directly in the main project or not. In my way, I create a NS plugin that includes the .aar library, then add this plugin to the main project & use the methods defined in the .aar library without problem. If you place the .aar library in the main project, you should check if that .aar library is installed by running tns build command & look at console log. If it's installed together with the project, that means you can use the lib method in .vue or any .js files.

1 Comment

Thank you for your response. I'm reffering to this link discourse.nativescript.org/t/import-aar-file-and-use-it-with-ns/… and it is possible to use the android lib directly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.