我在試圖構建我的項目時遇到了NullPointerException
。我目前聲明我的依賴關係properties
在頂層,則在子模塊(如下所示)參考:Gradle NPE在構建?
錯誤:
A problem occurred evaluating project ':myProject'.
> java.lang.NullPointerException (no error message)
Caused by: java.lang.NullPointerException
at org.gradle.util.GUtil.flatten(GUtil.java:69)
at org.gradle.util.GUtil.flatten(GUtil.java:66)
at org.gradle.util.GUtil.collectionize(GUtil.java:93)
at org.gradle.util.GUtil$collectionize.call(Unknown Source)
at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.methodMissing(DefaultDependencyHandler.groovy:
at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.invokeMethod(DefaultDependencyHandler.groovy)
頂層聲明:
ext.libraries = [
junit: 'junit:junit:4.12',
mockito: 'org.mockito:mockito-all:1.9.5'
]
參考子模塊中的屬性:
testCompile([
libraries.junit,
libraries.mockito
])
我收到子模塊中testCompile([
行的錯誤。什麼可能導致這個?
可能重複[什麼是空指針異常,以及如何解決它?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how -do-i-fix-it) –