如何 link NativeScript 插件中的本地 JAR 依赖项
How to link a local JAR dependency in a NativeScript Plugin
我正在构建一个 NativeScript 插件并包装来自 JAVA
库的一些功能。在大多数情况下,我看到用户在 src/platforms/android/include.gradle
中定义了 compile 'org.namespace:library:x.y.z'
的依赖项,但在我的情况下,该库在任何 JAVA 存储库中都不可用,并且是一个独立的 .jar
文件。
我已经尝试了用户对实际 Android
应用程序所做的一些建议,但当然 NativeScript 有点不同,到目前为止这些方法都不起作用。
我尝试过的步骤:
1) platforms/android/include.gradle
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile name: 'SimpleNetworking'
}
2) platforms/android/include.gradle
dependencies {
compile files('libs/SimpleNetworking.jar')
}
在需要此插件作为依赖项的 NativeScript 应用程序上进行测试时,两次尝试均以失败告终:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration
':app:debugCompileClasspath'.
> Could not find :SimpleNetworking:.
Required by:
project :app
可以找到我正在解决的具体插件here。
更新
阅读这篇关于构建依赖关系的 Android Studio Doc 并将 include.gradle
文件更改为如下内容后:
dependencies {
implementation files('libs/SimpleNetworking.jar')
}
好像找到文件了!现在看来坏掉的是别的东西:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Failed to transform file 'SimpleNetworking.jar' to match attributes {artifactType=processed-jar} using transform IdentityTransform
> Transform output file /Users/USERNAME/git/ons-testapp/platforms/android/app/libs/SimpleNetworking.jar does not exist.
我不确定这是相关错误还是新问题。
您只需将您的 JAR/AAR 文件放入 platforms/android,您的插件将在编译期间自动选取它。
我正在构建一个 NativeScript 插件并包装来自 JAVA
库的一些功能。在大多数情况下,我看到用户在 src/platforms/android/include.gradle
中定义了 compile 'org.namespace:library:x.y.z'
的依赖项,但在我的情况下,该库在任何 JAVA 存储库中都不可用,并且是一个独立的 .jar
文件。
我已经尝试了用户对实际 Android
应用程序所做的一些建议,但当然 NativeScript 有点不同,到目前为止这些方法都不起作用。
我尝试过的步骤:
1) platforms/android/include.gradle
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile name: 'SimpleNetworking'
}
2) platforms/android/include.gradle
dependencies {
compile files('libs/SimpleNetworking.jar')
}
在需要此插件作为依赖项的 NativeScript 应用程序上进行测试时,两次尝试均以失败告终:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration
':app:debugCompileClasspath'.
> Could not find :SimpleNetworking:.
Required by:
project :app
可以找到我正在解决的具体插件here。
更新
阅读这篇关于构建依赖关系的 Android Studio Doc 并将 include.gradle
文件更改为如下内容后:
dependencies {
implementation files('libs/SimpleNetworking.jar')
}
好像找到文件了!现在看来坏掉的是别的东西:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Failed to transform file 'SimpleNetworking.jar' to match attributes {artifactType=processed-jar} using transform IdentityTransform
> Transform output file /Users/USERNAME/git/ons-testapp/platforms/android/app/libs/SimpleNetworking.jar does not exist.
我不确定这是相关错误还是新问题。
您只需将您的 JAR/AAR 文件放入 platforms/android,您的插件将在编译期间自动选取它。