Android studio - 如何使用gradle中的可执行jar文件 [英] Android studio - How to use an executable jar file from gradle

查看:651
本文介绍了Android studio - 如何使用gradle中的可执行jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个custom_rules.xml文件,我试图在gradle中重建。到目前为止,我没有任何问题算出所有其他部分,但最后一部分我试图完成的是运行一个特殊的apk签名工具widevine drm对我生成的未签名的apk使用我的gradle构建过程。我一直在网上查找gradle文档,但我还没有找到如何从gradle运行可执行jar文件。我知道我必须创建一个任务,但这是关于它的。任何帮助将非常感激。

PS。我已阅读了很多gradle文档,所以请不要阅读文档回复。

编辑: p

是我目前的任务,它编译,但林不知道它实际上做任何事情

 任务(runApkSigTool,dependsOn: 'android',输入:JavaExec){

classpath files('apksigtool.jar')
main'com.widevine.tools.android.apksigtool.ApkSigTool'
args [ 0] = apkLocation
args [1] ='private_key.der'
args [2] ='my.crt'

}

我不确定是否必须像我的build.gradle文件的android部分中的方法那样使用它。

解决方案

您可以使用 JavaExec 任务。像这样:

 任务signApk(类型:JavaExec){
classpath文件('path / to / executable。 jar')
main'com.foo.MainClass'
args ['-foo','bar']
}


So I have a custom_rules.xml file Im trying to rebuild in gradle. so far I have no problem figuring everything else out but the last part Im trying to accomplish is running a special apk signing tool for widevine drm on the unsigned apk that I generate with my gradle build process. Ive been looking online and in the gradle documentation all day but I have yet to find how to run an executable jar file from gradle. I know I have to create a task but thats about it. Any help would be much appreciated.

PS. Ive read a lot of the gradle documentation so please spare me any read the docs responses

EDIT:

this is what my task looks like at the moment and it compiles but Im not sure its actually doing anything

task (runApkSigTool , dependsOn: 'android', type: JavaExec) {

classpath files('apksigtool.jar')
main 'com.widevine.tools.android.apksigtool.ApkSigTool'
args[0] = apkLocation
args[1] = 'private_key.der'
args[2] = 'my.crt'

}

Im not sure if I have to use it like a method in the android section of my build.gradle file or what.

解决方案

You could probably use the JavaExec task. Something like this:

task signApk(type: JavaExec) {
    classpath files('path/to/executable.jar')
    main 'com.foo.MainClass'
    args ['-foo', 'bar']
}

这篇关于Android studio - 如何使用gradle中的可执行jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆