我有一个包含两个模块的项目,今天早上从我尝试在两个模块上运行JUnit测试时开始我在我的gradle构建中出现此错误
错误:任务执行失败':usecases:compileDebugUnitTestJavaWithJavac'。 java.lang.reflect.InvocationTargetException
usecases是我的模块之一。
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':usecases:compileDebugUnitTestJavaWithJavac'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.internal.UncheckedException: java.lang.reflect.InvocationTargetException
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:45)
at net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:75)
at net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:24)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:104)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:53)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:206)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:187)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:130)
at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
... 20 more
Caused by: java.lang.reflect.InvocationTargetException
at net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:63)
... 36 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:144)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
at com.google.errorprone.BaseErrorProneJavaCompiler$1.call(BaseErrorProneJavaCompiler.java:99)
at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:119)
at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:66)
... 37 more
Caused by: java.lang.NullPointerException
at io.realm.processor.ModuleMetaData.getClassMetaDataFromModule(ModuleMetaData.java:130)
at io.realm.processor.ModuleMetaData.generate(ModuleMetaData.java:85)
at io.realm.processor.RealmProcessor.processModules(RealmProcessor.java:218)
at io.realm.processor.RealmProcessor.process(RealmProcessor.java:160)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:826)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:742)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:100)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1046)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1153)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1120)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:814)
at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:97)
at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:93)
at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:128)
... 44 more
的build.gradle:
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'maven'
apply plugin: 'realm-android'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "net.ltgt.errorprone"
version = "1.0.1"
group = "com.github.zeyad-37"
ext {
bintrayRepo = 'maven'
bintrayName = 'usecases'
publishedGroupId = 'com.github.zeyad-37'
libraryName = 'UseCases'
artifact = 'usecases'
libraryDescription = 'Is a library that is a generic implementation of the Domain and Data layers in a clean architecture.'
siteUrl = 'https://github.com/Zeyad-37/UseCases'
gitUrl = 'https://github.com/Zeyad-37/UseCases.git'
libraryVersion = version
developerId = 'zeyad-37'
developerName = 'Zeyad Gasser'
developerEmail = 'zeyad.gasser@gmail.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.10"
}
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
debuggable true
}
release {
}
}
lintOptions {
//lint rules of conduct
warningsAsErrors true
abortOnError true
htmlReport true
//locations for the rules and output
lintConfig file("${rootDir}/config/lint/lint-config.xml")
htmlOutput file("${buildDir}/reports/lint/lint.html")
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.all {
// All the usual Gradle options.
jvmArgs '-XX:MaxPermSize=256m'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
incremental false
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/rxjava.properties'
}
}
ext {
supportLibraryVersion = '25.3.1'
retrofitVersion = '2.3.0'
okhttpVersion = '3.8.0'
androidSupportTest = '0.5'
espressoCore = '2.2.2'
powerMock = '1.6.6'
robolectric = '3.3.2'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//Job Dispatcher
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0'
// Network
compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
compile "com.squareup.okhttp3:okhttp:$okhttpVersion"
compile "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
compile "com.android.support:support-annotations:$supportLibraryVersion"
// Rx
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex:rxjava:1.3.0'
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
// Cache
compile('com.github.lowlevel-studios:storo:1.1.0') {
transitive = true
}
// Testing
testCompile 'junit:junit:4.12'
testCompile "com.android.support:support-annotations:$supportLibraryVersion"
testCompile "com.android.support.test.espresso:espresso-core:$espressoCore"
testCompile "org.mockito:mockito-core:1.10.19"
testCompile "org.robolectric:robolectric:$robolectric"
testCompile "org.robolectric:shadows-support-v4:$robolectric"
testCompile "org.powermock:powermock-module-junit4:$powerMock"
testCompile "org.powermock:powermock-module-junit4-rule:$powerMock"
testCompile "org.powermock:powermock-api-mockito:$powerMock"
testCompile "org.powermock:powermock-classloading-xstream:$powerMock"
}
apply from: "$project.rootDir/tools/script-git-version.gradle"
apply from: "$project.rootDir/tools/script-findbugs.gradle"
apply from: "$project.rootDir/tools/script-pmd.gradle"
apply from: "$project.rootDir/tools/script-java-code-coverage.gradle"
apply from: "$project.rootDir/tools/script-infer.gradle"
apply from: "$project.rootDir/tools/script-check-style.gradle"
答案 0 :(得分:0)
我在apply plugin: 'android-apt'
文件中添加了build.gradle
。我不小心把它删除了。