gpt4 book ai didi

android - 无法在类型为 org.gradle.api.Project 的项目 ':app' 上找到参数的方法 androidTestCompile()

转载 作者:行者123 更新时间:2023-11-30 00:23:33 29 4
gpt4 key购买 nike

今天我安装了 Android Studio,打开程序后,我在 Gradle sync 部分的消息中看到了这个错误 ->


Error:(31, 0) Could not find method androidTestCompile() for arguments [com.android.support.test.espresso:espresso-contrib:2.2.2, build_4zwzygftganlohhaghm2dsums$_run_closure3@7658f1d6] on project ':app' of type org.gradle.api.Project.
<a href="openFile:C:\Users\Dany\AndroidStudioProjects\MyApplication3\app\build.gradle">Open File</a>

我的 gradle-module 中有这段代码 ->


apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.dany.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.+'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
}
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2'){
exclude module: 'support-annotations'
exclude module: 'support-v4'
exclude module: 'support-v13'
exclude module: 'recyclerview-v7'
exclude module: 'appcompat-v7'
}androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2'){
exclude module: 'support-annotations'
exclude module: 'support-v4'
exclude module: 'support-v13'
exclude module: 'recyclerview-v7'
exclude module: 'appcompat-v7'
}

最佳答案

在依赖 block 中用 androidTestImplementation 替换 androidTestCompile 对我有用。

关于android - 无法在类型为 org.gradle.api.Project 的项目 ':app' 上找到参数的方法 androidTestCompile(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45834629/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com