我正在构建NativeScript插件并包装JAVA
库中的某些功能。在大多数情况下,我已经看到用户在compile 'org.namespace:library:x.y.z'
中使用src/platforms/android/include.gradle
定义了一个依赖关系,但是在我的情况下,该库在任何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.
我不确定这是否是相关错误或新内容。
答案 0 :(得分:2)
您只需要将JAR / AAR文件放置在platform / android中,您的插件就会在编译过程中自动将其提取。