zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Androidstudio报错:Could not find method androidTestCompile()

报错 not Find could method AndroidStudio
2023-09-14 09:16:14 时间
  1. gradle报错:

Could not find method androidTestCompile() for arguments [directory 'libs']

原因:高版本的gradle已经不支持Compile()、TestCompile()、androidTestCompile()等。

  1. 解决
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

以上代码修改为:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:25.3.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
}