I am trying to run an old Android project, but have errors in the build.gradle (:app) file.
ndk_projects.each { File file ->
//noinspection GroovyAssignabilityCheck
task "copy $file" (dependsOn: "build $file", type:Copy) {
from "$buildDir/tmplibs"
into "$buildDir/libs"
}
//noinspection GroovyAssignabilityCheck
task "build $file" (dependsOn: ["copy $OpenNI2_path", "copy $OpenCL_path"], type:Exec) {
workingDir file
commandLine "${ndkDir}/ndk-build",
"NDK_PROJECT_PATH=${buildDir}/intermediates/ndk" ,
"NDK_APPLICATION_MK=${file.absolutePath}/jni/Application.mk" ,
"APP_BUILD_SCRIPT=${file.absolutePath}/jni/Android.mk",
"NDK_LIBS_OUT=${buildDir}/tmplibs"
environment NDK_MODULE_PATH: ndk_projects[0].absolutePath + "/jni" + ":" + OpenCL_path + "/obj/local/"
}
}
The error says task name must not contain any of the following characters: [/, \\, :, <, >, ", ?, *, |].
. As it uses the file path as the task name, so I should change that. A simple fix can be to remove all the slashes in the pathes and use that as a task name. But, I have zero knowledge about Gradle syntax. Can someone tell me how to do that? Thanks.
Gradle uses Groovy, which is generally compatible with Java. Groovy has a replaceAll
methods on String, which you can use here with a regex:
task "build ${file.path.replaceAll("[/\\\\:<>\"?*|]", ' ')}" (...) {
// ...
}
You can replace fewer characters if you'd like, this replaces all invalid characters to a space.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.