Android 我不能再运行JUnit测试了

Android 我不能再运行JUnit测试了,android,unit-testing,testing,android-gradle-plugin,realm,Android,Unit Testing,Testing,Android Gradle Plugin,Realm,我有一个包含两个模块的项目,从今天早上开始,每当我尝试在两个模块上运行JUnit测试时,我在gradle构建中都会遇到这个错误 错误:任务的执行失败:用例:CompiledBugUnitTestJavaWithJavaC。 java.lang.reflect.InvocationTargetException 用例是我的模块之一 build.gradle: apply plugin: 'com.android.library' apply plugin: 'me.tatarka.retrola

我有一个包含两个模块的项目,从今天早上开始,每当我尝试在两个模块上运行JUnit测试时,我在gradle构建中都会遇到这个错误

错误:任务的执行失败:用例:CompiledBugUnitTestJavaWithJavaC。 java.lang.reflect.InvocationTargetException

用例是我的模块之一

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"

我在我的
build.gradle
文件中添加了:
apply插件:“android apt”
。我之前不小心把它拿走了

单堆栈跟踪行没有多大帮助。你能发布整个堆栈跟踪吗?没有更多的堆栈跟踪了,我上传了一个屏幕shot@ZeyadGasser有,它甚至告诉你在哪里。查看
Gradle控制台
工具窗口。@Vampile我添加了Gradle堆栈跟踪。这对我没有太大的帮助,我认为它太大了,无法运行。你能正常构建并生成apk吗?你能发布你的
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"