Java 我正在尝试使用junit和apt插件

Java 我正在尝试使用junit和apt插件,java,android,unit-testing,junit,android-gradle-plugin,Java,Android,Unit Testing,Junit,Android Gradle Plugin,我正在尝试在我的android应用程序中使用JUnit。我有这个build.gradle/app配置: apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com

我正在尝试在我的android应用程序中使用JUnit。我有这个build.gradle/app配置:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.myproject.tv"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


repositories { jcenter() }

apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName android.defaultConfig.applicationId
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12' //added
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'
    compile 'com.android.support:leanback-v17:23.2.0'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.github.bumptech.glide:glide:3.4.+'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
    compile 'com.android.support:support-v4:23.2.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.danikula:videocache:2.3.3'
    compile 'org.androidannotations:androidannotations-api:3.3.2'
    apt 'org.androidannotations:androidannotations:3.3.2'
    compile 'com.google.dagger:dagger:2.0.2'
    apt 'com.google.dagger:dagger-compiler:2.0.2'
    provided 'org.glassfish:javax.annotation:10.0-b28'
}
运行应用程序时:

Error:(28, 0) Cannot get property 'processResources' on null object
<a href="openFile:E:\AndroidProject\JoinTV\app\build.gradle">Open File</a>
如何在gradle中解决此问题

我遇到了同样的问题

删除
testCompile'junit:junit:4.12'
//添加

然后同步您将修复

我遇到了相同的问题

Try this. It worked for me.
<pre><code>  
    apt {
        arguments {
            androidManifestFile variant.outputs[0]?.processResources?.manifestFile
            resourcePackageName android.defaultConfig.applicationId
        }
    }
</code></pre>
删除
testCompile'junit:junit:4.12'
//添加

然后同步您将修复

Try this. It worked for me.
<pre><code>  
    apt {
        arguments {
            androidManifestFile variant.outputs[0]?.processResources?.manifestFile
            resourcePackageName android.defaultConfig.applicationId
        }
    }
</code></pre>

是的,它与
testCompile'junit:junit:4.12'
一起工作,解决op的问题啊,它与
testCompile'junit:junit:4.12'
一起工作,解决op的问题这不是答案。OP希望在您的项目中使用
junit
。这不是答案。OP希望在项目中使用
junit