Implementing native android .aar file or .aidl in Nativescript throws native calss object without access to methods
Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
- CLI:
- Cross-platform modules:
- Android Runtime:
- iOS Runtime:
- Plugin(s): Android Describe the bug
I have an Android SDk done with java whic I already converted to .aar file. I created a plugin and placed the aar file in App_Resources/Android/libs directory. In my index.js file, I have this
var intent = new android.content.Intent(application.android.foregroundActivity, com.iposprinter.printertestdemo.IPosPrinterTestDemo.class)
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
application.android.foregroundActivity.startActivity(intent);
This cause the sdk to display.
Doing this
var iposprinter=new com.iposprinter.printertestdemo.IPosPrinterTestDemo()
console.log(iposprinter) //outputs com.iposprinter.printertestdemo.IPosPrinterTestDemo@682890e
while this `console.log(iposprinter.printerInit) outputs undefined`
while this
`console.log(iposprinter.printerInit) outputs undefined`
console.log(iposprinter.printerInit()) outputs undefined
TypeError: iposprinter.printerInit is not a function
How do I call methods from this package? To Reproduce
Expected behavior
Sample project
Additional context
Did you get to solve this?
Not at all. Any luck pls?
Your code on the surface looks like it should work.
However, without actually seeing the .aar, it is hard to say for sure why it isn't work. It is possible that your class or methods are marked as private, or something simular.
- If you need a NDA to send the aar, we can sign one. Or if you want to add me to a public/private project, we can help you get it working.
- You can try running the dts generator and then putting the .d.ts files for your plugin in this message so we can see what it is seeing: https://github.com/NativeScript/android-dts-generator
Hello Nathaniel Anderson, A very goody to you and a happy new month in Nigeria time. I had to drop the project when I couldn’t get any solution to what I was facing but not withstanding, since you are willing to assist, I will be adding to you the project so as to complete it.
Thank you
On Sep 1, 2020, at 12:41 AM, Nathanael Anderson [email protected] wrote:
Your code on the surface looks like it should work. However, without actually seeing the .aar, it is hard to say for sure why it isn't work. It is possible that your class or methods are marked as private, or something simular.
If you need a NDA to send the aar, we can sign one. Or if you want to add me to a public/private project, we can help you get it working. You can try running the dts generator and then putting the .d.ts files for your plugin in this message so we can see what it is seeing:https://github.com/NativeScript/android-dts-generator https://github.com/NativeScript/android-dts-generator — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NativeScript/android-runtime/issues/1535#issuecomment-684104139, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGX4IBLNFJOF3AK4TC3JOIDSDQYKLANCNFSM4JKTP7VQ.