微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

导入模块构建时出现Android错误,gradle – 无法找到方法instrumentTestCompile()

在导入ListViewAnimation库时,我得到重建错误

Error:(7) A problem occurred evaluating project ':library'.

Could not find method instrumentTestCompile() for arguments [org.mockito:mockito-core:1.9.5, build_n73cqp2judtlhpna5h10rio8c$_run_closure1_closure3@20e75be5] on project ‘:library’.

这是导入的模块build.gradle:

    apply plugin: 'android-library'


dependencies {
    compile 'com.nineoldandroids:library:2.4.0'

    instrumentTestCompile ('org.mockito:mockito-core:1.9.5')  { exclude group: 'org.hamcrest' }
    instrumentTestCompile ('com.google.dexmaker:dexmaker-mockito:1.0')  { exclude group: 'org.hamcrest' }
    instrumentTestCompile ('junit:junit:4.11')  { exclude group: 'org.hamcrest' }
    instrumentTestCompile 'org.hamcrest:hamcrest-all:1.3'
}

android {
    compileSdkVersion 19
    buildToolsversion '19.0.1'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
        instrumentTest {
            java.srcDirs = ['tests/java']
        }
    }

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionName project.VERSION_NAME
        versionCode Integer.parseInt(new Date().format('yyyyMMddHH'))
    }

    packagingOptions {
        exclude 'LICENSE.txt'
    }
}

apply from: '../maven_push.gradle'

问题是什么 ?

解决方法:

在最近的android-gradle-plugin中,instrumentTest已经在androidTest中重命名

您必须在build.gradle中重命名

> instrumentTestCompile – > androidTestCompile
> instrumentTest – > androidTest

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐