Windows上build.gradle中的绝对路径 我在gradle.properties中定义了到密钥库的绝对路径 我正在使用Windows
我在小路上有一块空地 RELEASE_STORE_FILE=“D:\My Folder\Android\Android.javakeystore.keystore.jks” 我收到了错误Windows上build.gradle中的绝对路径 我在gradle.properties中定义了到密钥库的绝对路径 我正在使用Windows,gradle,Gradle,我在小路上有一块空地 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.WinNTFileSyste
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
如何在Gradle中正确定义Windows上的绝对路径?问题来自Gradle.properties文件中属性值中的“环绕”字符。您应该在Gradle.properties中配置属性,如下所示:
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
其他例子说明了这一点:
格拉德尔酒店
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
格雷德尔先生
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
你试过双反斜杠吗?
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