错误:错误:找不到 org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency{group='com.android.support.test.espresso', name='espresso-core', version='2.2.2', configuration='default'} 上的参数 [com.android.support:design:27.1.0] 的方法实现((。
请从 Android SDK Manager 安装 Android Support Repository。打开安卓软件开发工具包管理器
build.gradle (Module app(
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.example.salmakhalil.signupformwithdatabase"
minSdkVersion 14
targetSdkVersion 28
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.2.2', {
// androidTestCompile 'com.android.support:support-annotations:27.1.0'
exclude group: 'com.android.support', module: 'support-annotations'
implementation 'com.android.support:design:27.1.0'
// implementation 'com.android.volley:volley:1.1.0'
//implementation 'com.android.support:appcompat-v7:27.1.0'
// implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// implementation 'junit:junit:4.12'
// implementation 'com.android.support.test:runner:1.0.1'
// implementation 'com.android.support.test.expresso:expresso-core:3.0.1'
})
compile 'com.android.support:appcompat-v7:25.+'
testCompile 'junit:junit:4.12'
}
我应该如何解决这个问题?
**build.gradle** (Module App)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.example.salmakhalil.signupformwithdatabase"
minSdkVersion 14
targetSdkVersion 28
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.2.2', {
// androidTestCompile 'com.android.support:support-annotations:27.1.0'
exclude group: 'com.android.support', module: 'support-annotations'
implementation 'com.android.support:design:27.1.0'
// implementation 'com.android.volley:volley:1.1.0'
//implementation 'com.android.support:appcompat-v7:27.1.0'
// implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// implementation 'junit:junit:4.12'
// implementation 'com.android.support.test:runner:1.0.1'
// implementation 'com.android.support.test.expresso:expresso-core:3.0.1'
})*/
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0-alpha09'
compile 'com.android.support:appcompat-v7:25.+'
testCompile 'junit:junit:4.12'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
// { url "https://jitpack.io" }
//maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
/*configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:27.1.0'
}*/```
首先更新 gradle 和 gradle 版本的 android 插件版本。
在项目build.gradle
(顶级文件(中更新 android 插件更改:
repositories {
google() //<-- add
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2' //change
}
}
allprojects {
repositories {
google() //<-- add
maven { url 'http://repo1.maven.org/maven2' }
}
}
然后在gradle/wrapper/gradle-wrapper.properties
使用distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
更改 gradle 版本。
要修复问题中的问题,请在module/build.gradle
更改中:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
// androidTestCompile 'com.android.support:support-annotations:27.1.0'
exclude group: 'com.android.support', module: 'support-annotations'
implementation 'com.android.support:design:27.1.0'
})
自:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation 'com.android.support:design:27.1.0'
更改
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
// androidTestCompile 'com.android.support:support-annotations:27.1.0'
exclude group: 'com.android.support', module: 'support-annotations'
implementation 'com.android.support:design:27.1.0'
})
自
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0-alpha09'
从这里更改以下代码:
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
对此:
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0-alpha09'
然后添加 gradle 属性:
android.useAndroidX=true