My English is poor.
I'm a FRONT-END developer.
Now we need an App can use Bluetooth Printer, coding with React-Native for Android.
The Printer's manufacturer provided a SDK file,extension is 'jar'.
Please tell me how to use this SDK in the React-Native? then how to import in the JSX files?
To integrate jar file to android see here.
In order to access the library functionality you need to create a react-native module for the functionalities which you want to access through javascript. For more info refer this
Adding
*.jar
to the Project is done by usingbuild.gradle
file:jar
file to the project, Facebook had already done on your behalf!Just add a
libs
folder into theandroid/app
directory of the project with yourjar
file and enjoy!jar
file to anative-module
then add the line ofcompile fileTree(dir: "libs", include: ["*.jar"])
into thedependencies
part ofbuild.gradle
file of the native-module.Example-1:
After I added okhttp-3.4.1.jar file into the lib folder, I also add that package name to the dependencies part as the following:
Example-2:
If I need another package -that is found in Maven repo- I have to add into dependencies block as following (for instance I wanna add
fresco
):Then Gradle will find and install dependency library Fresco for me.
Usually, every Android project has already Maven repo. configurations in
build.gradle
file which is found in top of folder of the project. For example:Example-3:
(I have never tried this however it should be worked)
If I have an
drawee-debug.aar
file I can add it into my project by putting it intolib
folder as directed on Example-1 then I have to changefileTree
line as following:Example-4:
(alternate way of Example-3)
If I have an
drawee-debug.aar
file also I can add it into my project by putting it intolib
folder as directed on Example-1 then I have to change and add some lines as following:In this way,
libs
directory is defined inallprojects
folder andaar
file specified independencies
block, like othe examples.Note that after Gradle v3.0.1
implementation
is used insteadcompile
key word.Kudos: https://stackoverflow.com/a/37092426/3765109