【发布时间】:2016-03-22 18:13:39
【问题描述】:
我正在尝试在我的 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>
第 28 行是:
26 apt {
27 arguments {
28 androidManifestFile variant.outputs[0].processResources.manifestFile
29 resourcePackageName android.defaultConfig.applicationId
30 }
31}
如何在我的 gradle 中解决这个问题???
【问题讨论】:
标签: java android unit-testing junit android-gradle-plugin