Абсолютные пути в build.gradle в Windows - PullRequest
0 голосов
/ 25 августа 2018
  • Я определил абсолютный путь в gradle.properties к хранилищу ключей
  • Я использую Windows
  • У меня пустое место на пути

    RELEASE_STORE_FILE = "D: \ Моя папка \ 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?

1 Ответ

0 голосов
/ 25 августа 2018

Проблема исходит от окружающего "символа в значении вашего свойства из файла 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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...