我正在为cordova v5.0.0做一个插件 该插件适用于gradle依赖项,但我需要使用jar文件
所以我将文件添加到plugin.xml
的源代码部分<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="SygicPlugin">
<param name="android-package" value="com.test.plugi"/>
</feature>
</config-file>
<source-file src="src/android/libs/MyJar.jar" target-dir="src/libs/" />
<source-file src="src/android/MyPlugin.java" target-dir="src/" />
<framework src="src/android/build.gradle" custom="true" type="gradleReference" />
</platform>
这是我的build.gradle文件
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
但是android构建过程失败了:
MyPlugin.java:4:错误:包com.test.jars.model不存在 import com.jar.jarType;
我找到了许多使用ant进行构建的“示例”,但我正在使用gradle,我想继续使用它。
您是否知道如何使用插件中的jar并正确配置gradle以进行构建?
提前致谢。
w ^
答案 0 :(得分:1)
主要问题是它没有找到jar文件,但它无声地失败。 当我将文件更改为:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile name: 'MyJar'
}
我可以看到错误。路径库不存在。 所以我需要使用我的plugin.xml文件src / lib中使用的相同路径到我的jar。这很明显......我觉得自己像个菜鸟:)
我的最终build.gradle文件是:
dependencies {
compile fileTree(dir: 'src/libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}