gpt4 book ai didi

Android - 错误 : package android. support.test 不存在

转载 作者:行者123 更新时间:2023-12-04 01:52:45 26 4
gpt4 key购买 nike

我尝试运行单元测试,但出现错误

error: package android.support.test does not exist



在我的成绩文件中,我有
testImplementation 'junit:junit:4.12'
androidTestCompile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'

但我仍然收到错误

Gradle
import java.util.regex.Pattern


apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
apply from: 'versionCode.gradle'


android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
versionName "1.0." + VERSION_CODE
versionCode Integer.parseInt(VERSION_CODE)
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
res.srcDirs =
[...]
java.srcDirs = ['src/main/java', 'src/main/java/UserStories']
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}

repositories {
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }

maven { url 'https://maven.fabric.io/public' }
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'jniLibs', include: ['*.jar', '.so'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'co.lujun:androidtagview:1.1.4'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'jp.wasabeef:glide-transformations:3.0.1'
compile "com.daimajia.swipelayout:library:1.2.0@aar"
implementation 'com.tapadoo.android:alerter:2.0.6'

compile group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.1.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

testImplementation "org.mockito:mockito-core:2.+"
testImplementation 'junit:junit:4.12'

compile fileTree(dir: 'libs', include: ['*.jar'])
testImplementation "org.robolectric:robolectric:3.8"
compile('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true;
}
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}

implementation 'com.google.dagger:dagger-android:2.11'
implementation 'com.google.dagger:dagger-android-support:2.11'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
}


tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig') {
task.dependsOn 'increaseVersionCode'
}
}

最佳答案

确保你的 gradle 文件是这样的:

android {
...
defaultConfig {
...
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
...
}
...
}
dependencies {
...
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
...
}

它现在有效吗?

关于Android - 错误 : package android. support.test 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52164473/

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