gradle.properties
中定义了到密钥库的绝对路径路径上有空白
RELEASE_STORE_FILE =“ D:\ My Folder \ Android \ android.javakeystore.keystore.jks”
我收到错误
The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
at java.io.File.getCanonicalPath(File.java:618)
at java.io.File.getCanonicalFile(File.java:643)
at org.gradle.api.internal.file.FileNormaliser.normalise(FileNormaliser.java:54)
... 222 more
如何在Windows中正确地在Gradle中定义绝对路径?
答案 0 :(得分:2)
问题来自 gradle.properties 文件中属性值中的周围“”字符。您应按以下方式在 gradle.properties 中配置属性:
RELEASE_STORE_FILE=D:\\My Folder\\Android\\android.javakeystore.keystore.jks
或
RELEASE_STORE_FILE=D:/My Folder/Android/android.javakeystore.keystore.jks
Gradle会保留属性值中的“”字符,因此,如果您尝试类似的操作:
file(RELEASE_STORE_FILE).exits() // if RELEASE_STORE_FILE contains " char, it will fail
其他示例来说明这一点:
gradle.properties
cert_path_1=c:/my certs/cert.txt
cert_path_2="c:/my certs/cert.txt"
cert_path_3="c:\\my certs\\cert.txt"
cert_path_4=c:\\my certs\\cert.txt
build.gradle
void testFile(String message, String fileToTest){
println message
println " -> does the file exist? : " + file(fileToTest).exists() + "\n"
}
testFile("Testing property 'cert_path_1'", ext.cert_path_1)
testFile("Testing property 'cert_path_2'", ext.cert_path_2)
testFile("Testing property 'cert_path_3'", ext.cert_path_3)
testFile("Testing property 'cert_path_4'", ext.cert_path_4)
结果:
Testing property 'cert_path_1'
-> does the file exist? : true
Testing property 'cert_path_2'
-> does the file exist? : false
Testing property 'cert_path_3'
-> does the file exist? : false
Testing property 'cert_path_4'
-> does the file exist? : true