我不明白,为什么gradle不构建?我使用Android Studio,Gradle 1.12。
的build.gradle
apply plugin: 'android'
apply plugin: 'android-test'
apply plugin: "jacoco"
repositories {
maven { url '***' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
testPackageName "***"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
buildTypes {
debug {
packageNameSuffix ".debug"
runProguard false
testCoverageEnabled = true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
jacoco {
version = '0.6.2.201302030002'
}
testOptions {
resultsDir = "$project.buildDir/jacoco"
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.activeandroid:activeandroid:3.1'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:4.4.52'
compile 'com.squareup.picasso:picasso:2.2.0'
testCompile('org.mockito:mockito-all:1.9.5') {
exclude module: 'hamcrest'
}
compile 'com.google.dexmaker:dexmaker-mockito:1.0'
testCompile 'com.google.dexmaker:dexmaker:1.0'
testCompile 'junit:junit:4.11'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
}
当我将gradle与项目同步时,它会发出警告:
信息:Gradle任务[:app:generateDebugSources] 警告:按需配置是一项孵化功能。 警告:依靠包装来定义主要的扩展名 工件已被弃用,计划在Gradle中删除 2.0警告:不推荐使用Test.testReportDir属性,并计划在Gradle 2.0中将其删除。请使用 而是测试.getReports()。getHtml()。getDestination()属性。 :app:preBuild:app:preDebugBuild:app:checkDebugManifest :app:preReleaseBuild:app:preStageBuild :app:prepareComGoogleAndroidGmsPlayServices4452Library UP-TO-DATE :app:prepareDebugDependencies:app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE:app:generateDebugBuildConfig UP-TO-DATE:app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE:app:generateDebugResources UP-TO-DATE:应用程序:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE:app:processDebugResources 最新消息:app:generateDebugSources UP-TO-DATE信息:BUILD 成功信息:总时间:6.457秒信息:0错误 信息:3个警告
答案 0 :(得分:1)
问题出在插件“gradle-android-test-plugin”中。 JakeWharton宣布这个插件被弃用了。 Maby可能是因为这不会投射。我删除了插件并更改了build.gradle文件:
apply plugin: 'android'
apply plugin: "jacoco"
repositories {
maven { url '***' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
testPackageName "***"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
testHandleProfiling true
testFunctionalTest true
}
packagingOptions {
exclude 'LICENSE.txt'
}
buildTypes {
debug {
packageNameSuffix ".debug"
runProguard false
testCoverageEnabled = true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
test {
packageNameSuffix ".test"
runProguard false
testCoverageEnabled = true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
jacoco {
version = '0.6.2.201302030002'
}
testOptions {
resultsDir = "$project.buildDir\\jacoco"
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.activeandroid:activeandroid:3.1'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:4.4.52'
compile 'com.squareup.picasso:picasso:2.2.0'
compile('org.mockito:mockito-all:1.9.5') {
exclude module: 'hamcrest'
}
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
androidTestCompile 'com.google.dexmaker:dexmaker:1.0'
androidTestCompile 'junit:junit:4.11'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
}