gpt4 book ai didi

android - 应用程序 (1.1) 和测试应用程序 (1.3) 的已解决版本不同

转载 作者:行者123 更新时间:2023-12-03 05:50:20 25 4
gpt4 key购买 nike

我是android和gradle的初学者。我看到了这个错误,所以我从我的模块 gradle 中删除了 hamcrest 依赖项,但我仍然看到以下错误:

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.

Conflict with dependency 'org.hamcrest:hamcrest-core' in project ':app'. Resolved versions for app (1.1) and test app (1.3) differ.



这种依赖性导致了问题:
compile 'com.android.support.test:testing-support-lib:0.1'

应用等级:
buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

模块 gradle(我有一个模块):
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.stavalfi.app1"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.android.gms:play-services-maps:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
compile 'com.android.support:support-annotations:22.2.0'
androidTestCompile 'com.android.support.test:runner:1.0.0'
androidTestCompile 'com.android.support.test:rules:1.0.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0'
compile 'com.android.support.test:testing-support-lib:0.1'
compile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0'
}//testImplementation



apply plugin: 'com.google.gms.google-services'

我试过的:
//testCompile 'junit:junit:4.12'
testCompile('junit:junit:4.12') { // Prevent duplication conflicts
exclude module: 'hamcrest-core'
exclude module: 'hamcrest-library'
exclude module: 'hamcrest-integration'
}

但我得到同样的错误。

我也看到了这个解决方案,但我不知道在哪里准确添加配置:

Robolectric 3.0-rc2 Hamcrest-core conflict

如果我不使用hamcrest,我不明白为什么我需要遇到这个问题。

谢谢!

最佳答案

在 buildtypes 下添加 configuration.all。

配置.all {}

 android {
compileSdkVersion 26
defaultConfig {
applicationId "com.nfs.ui.notesapp"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}


configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:24.0.0'
}

}

关于android - 应用程序 (1.1) 和测试应用程序 (1.3) 的已解决版本不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48176830/

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