Gradle String index超出范围:0

时间:2016-09-20 06:04:57

标签: gradle gradlew

我正在记录我在这里遇到的问题,因为我在寻找解决方案之前已经找了很长时间。我希望它能帮助别人......

我遇到的问题是每当我使用Gradle 2.14.x执行任何gradle任务时,我都会遇到异常String index out of range: 0。 Gradle 2.12.x一切正常。

调试输出也不是很有帮助:

$ gradle compileJava --debug
...
18:39:40.880 [INFO] [org.gradle.BuildLogger] Starting Build
18:39:40.880 [DEBUG] [org.gradle.BuildLogger] Gradle user home: /home/olivier/.gradle
18:39:40.881 [DEBUG] [org.gradle.BuildLogger] Current dir: /home/olivier/Workspace/my-project
18:39:40.881 [DEBUG] [org.gradle.BuildLogger] Settings file: null
18:39:40.881 [DEBUG] [org.gradle.BuildLogger] Build file: null
18:39:40.882 [DEBUG] [org.gradle.initialization.buildsrc.BuildSourceBuilder] Starting to build the build sources.
18:39:40.882 [DEBUG] [org.gradle.initialization.buildsrc.BuildSourceBuilder] Gradle source dir does not exist. We leave.
18:39:40.882 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found env project properties: []
18:39:40.883 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found system project properties: []
18:39:40.884 [DEBUG] [org.gradle.initialization.ScriptEvaluatingSettingsProcessor] Timing: Processing settings took: 0.001 secs
18:39:40.885 [INFO] [org.gradle.BuildLogger] Settings evaluated using settings file '/home/olivier/Workspace/my-project/settings.gradle'.
18:39:40.885 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Transitioning model element '<root>' from state Registered to Created
18:39:40.886 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Transitioning model element '<root>' to state Discovered.
18:39:40.886 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Transitioning model element '<root>' to state Created.
18:39:40.887 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks' (hidden = false)
18:39:40.888 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Transitioning model element 'tasks' from state Registered to Created
18:39:40.888 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Running model element 'tasks' rule action Project.<init>.tasks()
18:39:40.888 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Mutating tasks using Project.<init>.tasks()
18:39:40.889 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Transitioning model element 'tasks' to state Discovered.
18:39:40.889 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Running model element 'tasks' rule action Project.<init>.tasks()
18:39:40.890 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Mutating tasks using Project.<init>.tasks()
18:39:40.890 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Transitioning model element 'tasks' to state Created.
18:39:40.892 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'serviceRegistry' (hidden = true)
18:39:40.893 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'buildDir' (hidden = true)
18:39:40.893 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'projectIdentifier' (hidden = true)
18:39:40.894 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'extensionContainer' (hidden = true)
18:39:40.894 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'fileOperations' (hidden = true)
18:39:40.894 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'sourceDirectorySetFactory' (hidden = true)
18:39:40.895 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'taskFactory' (hidden = true)
18:39:40.895 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'instantiator' (hidden = true)
18:39:40.896 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'typeConverter' (hidden = true)
18:39:40.896 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'nodeInitializerRegistry' (hidden = true)
18:39:40.896 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'structBindingsStore' (hidden = true)
18:39:40.897 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'proxyFactory' (hidden = true)
18:39:40.897 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'schemaStore' (hidden = true)
18:39:40.898 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Looking for project properties from: /home/olivier/Workspace/my-project/gradle.properties
18:39:40.898 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] project property file does not exists. We continue!
18:39:40.899 [ERROR] [org.gradle.BuildExceptionReporter] 
18:39:40.899 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
18:39:40.899 [ERROR] [org.gradle.BuildExceptionReporter] 
18:39:40.899 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
18:39:40.900 [ERROR] [org.gradle.BuildExceptionReporter] String index out of range: 0
18:39:40.900 [ERROR] [org.gradle.BuildExceptionReporter] 
18:39:40.900 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
18:39:40.900 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 
18:39:40.900 [LIFECYCLE] [org.gradle.BuildResultLogger] 
18:39:40.901 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
18:39:40.901 [LIFECYCLE] [org.gradle.BuildResultLogger] 
18:39:40.901 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 0.635 secs
...

我从互联网上的不同帖子中读到的是,这是由于我的属性文件中的语法错误。但即使完全清空后,我也无法让Gradle跑。

1 个答案:

答案 0 :(得分:0)

问题确实发生在我的一个属性文件中:~/.gradle/gradle.properties包含字符串:::properties,我已经通过文档中的错误复制并粘贴了该文件。