0

I have to use an npm library from an Android native app. The app is a CAD-compatible app which should export to DXF or DWG, and since DXF libraries on Java are either proprietary or outdated, I have to rely on options on other languages. (Sure, it might fall into an XY problem, but using other languages will also stumble into this kind of problem-like Python or C#.)

How do I call the library from inside? Compared to similar questions and existing solutions,

  • This solution by Janea Systems is the closest to what I want to achieve, but it seems to be outdated.
  • This question, this question and this question all present outdated solutions or solutions which has to be installed by the user. I want the libraries bundled by the vendor as part of the app.
  • Making a React Native app would be the most flawless way, but it is not feasible at this stage. I already implemented the core functionality of the app except for the export feature at this stage.
Arle Camille
  • 163
  • 1
  • 12
  • Have you looked at [ADXF](https://jsevy.com/wordpress/index.php/java-and-android/android-apps-and-libraries/android-adxf-library/) and [JDXF](https://jsevy.com/wordpress/index.php/java-and-android/jdxf-java-dxf-library/)? – Ricky Mo Dec 14 '22 at 05:04
  • @RickyMo JDXF doesn't support Android (because they use classes explicit to Oracle Java), while ADXF does not support ONE header (metric) that is required for my app. – Arle Camille Dec 14 '22 at 05:09

1 Answers1

0

As per this document in the React Native official website, you can switch an existing app to a React Native app simply by adding a ReactRootView somewhere in the application hierarchy and adding corresponding JavaScript components. That means an activity requiring a Node functionality as in my scenario can easily be delegated onto an activity with a ReactRootView as its root view. Your entire app don't have to be React-capable if you don't aim for multiplatform capability.

You are likely to stumble into issues, however. Obviously you have to setup a React Native development environment first, you have to specify your package name on the manifest on the contrary of what Android Studio tells you to (if you find how not to, please tell me), and android.permission.INTERNET and android.permission.SYSTEM_ALERT_WINDOW (for debug builds) have to be given to the application.

In my scenario, I had to forward data to the Node library and save the result as a file. I launched the activity in the one-shot manner and returned to the native app from within the JavaScript code.

Arle Camille
  • 163
  • 1
  • 12