我正在尝试使用gradle自动化我的应用程序构建过程。构建步骤之一是从android libraries项目生成dex文件。这些项目是主要的应用程序模块,并在运行时加载。在当前的构建过程中,我正在构建库的jar并使用脚本将其转换为dex。这是通过eclipse build命令完成的。有没有一种方法和如何做到这一点与gradle?
kxe2p93d1#
您需要手动调用dx eg。
dx
task finalize() { doFirst { println('Encrypting!') println("${projectDir}") exec { workingDir "${projectDir}/build/intermediates/classes/debug" commandLine "/home/MyUser/Android/Sdk/build-tools/26.0.0/dx" \ , "--dex" \ , "--output=my/example/com/secureme/SecuredData.dex" \ , "my/example/com/secureme/SecuredData.class" } //We don't want in our APK this .class project.delete "build/intermediates/classes/debug/my/example/com/secureme/SecuredData.class" // Encrypt our .dex file encrypt.execute() copy { from "build/intermediates/classes/debug/my/example/com/secureme/SecuredData.dex" into "src/main/assets/" } }}tasks.withType(JavaCompile) { compileTask -> compileTask.finalizedBy finalize }
task finalize() {
doFirst {
println('Encrypting!')
println("${projectDir}")
exec {
workingDir "${projectDir}/build/intermediates/classes/debug"
commandLine "/home/MyUser/Android/Sdk/build-tools/26.0.0/dx" \
, "--dex" \
, "--output=my/example/com/secureme/SecuredData.dex" \
, "my/example/com/secureme/SecuredData.class"
}
//We don't want in our APK this .class
project.delete "build/intermediates/classes/debug/my/example/com/secureme/SecuredData.class"
// Encrypt our .dex file
encrypt.execute()
copy {
from "build/intermediates/classes/debug/my/example/com/secureme/SecuredData.dex"
into "src/main/assets/"
tasks.withType(JavaCompile) { compileTask -> compileTask.finalizedBy finalize }
字符串完整示例here
1条答案
按热度按时间kxe2p93d1#
您需要手动调用
dx
eg。字符串
完整示例here