ass*_*ert 8 javascript java frontend android react-native
我的英文程度不高.
我是前端开发人员.
现在我们需要一个App可以使用蓝牙打印机,使用React-Native for Android进行编码.
打印机的制造商提供了一个SDK文件,扩展名为'jar'.
请告诉我如何在React-Native中使用此SDK?那么如何在JSX文件中导入?
efk*_*kan 17
*.jar通过使用build.gradle文件添加到项目:
jar在项目中添加一个文件,Facebook已经代表你做了!libs文件夹添加到android/app项目目录中即可jar享受!jar文件添加到a,native-module则将该行添加compile fileTree(dir: "libs", include: ["*.jar"])到本机模块dependencies的build.gradle文件部分中.实施例-1:
在我将okhttp-3.4.1.jar文件添加到lib文件夹后,我还将该包名称添加到依赖项部分,如下所示:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile 'com.facebook.react:react-native:0.19.+'
}
Run Code Online (Sandbox Code Playgroud)
实施例-2:
如果我需要另一个包 - 在Maven repo中找到 - 我必须添加到依赖块中,如下所示(例如我想添加fresco):
dependencies {
compile 'com.facebook.fresco:fresco:1.9.0'
}
Run Code Online (Sandbox Code Playgroud)
然后Gradle将为我找到并安装依赖库Fresco.
通常,每个Android项目都已经有Maven回购.build.gradle文件中的配置,位于项目文件夹的顶部.例如:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Run Code Online (Sandbox Code Playgroud)
实施例-3:
(我从来没有尝试过这应该工作)
如果我有一个drawee-debug.aar文件,我可以将它添加到我的项目中,lib按照示例1的指示将其放入文件夹然后我必须更改fileTree如下行:
compile fileTree(dir: "libs", include: ["*.jar", "*.aar"]) // "*.aar" is added
Run Code Online (Sandbox Code Playgroud)
实施例-4:
(示例-3的替代方式)
如果我有一个drawee-debug.aar文件,我可以将它添加到我的项目中,方法是lib按照Example-1 的说明将其添加到文件夹中,然后我必须更改并添加一些如下行:
dependencies {
compile (name:'drawee-debug', ext:'aar')
}
allprojects {
repositories {
...
flatDir {
dirs 'libs', './libs'
}
...
}
}
Run Code Online (Sandbox Code Playgroud)
通过这种方式,libs目录在块中指定的allprojects文件夹和aar文件中定义dependencies,就像其他示例一样.
请注意,implementation使用Gradle v3.0.1 代替compile关键字后.
荣誉:https://stackoverflow.com/a/37092426/3765109
| 归档时间: |
|
| 查看次数: |
7096 次 |
| 最近记录: |