程序类型已经存在:org.xmlpull.v1.XmlPullParserException

时间:2018-10-09 08:56:44

标签: android gradle robolectric

将robolectric添加到build.gradle文件后,我得到了错误

  

程序类型已经存在:org.xmlpull.v1.XmlPullParserException。

我已经尝试使用exclude 'org.xmlpull.v1'configurations.all中的androidTestImplementation 'org.robolectric:robolectric:3.8',但是没有用。

这是build.gradle文件。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.2'
    defaultConfig {
        applicationId "com.app.aim_app"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    testOptions {
        execution 'ANDROID_TEST_ORCHESTRATOR'
        unitTests {
            includeAndroidResources = true
        }
    }
}

repositories {
    mavenCentral()
    google()
    maven {
        url 'https://maven.google.com'
    }
    jcenter()
    maven {
        name 'glide-snapshot'
        url 'http://oss.sonatype.org/content/repositories/snapshots'
    }
}

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

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0', files('/libs/App42MultiPlayerGamingSDK.jar')
    testImplementation 'junit:junit:4.12'
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation 'com.android.support:support-annotations:28.0.0'
    implementation "com.android.support.test.espresso.idling:idling-concurrent:3.0.2"

    androidTestUtil 'com.android.support.test:orchestrator:1.0.2'

    androidTestImplementation 'org.robolectric:robolectric:3.8'
}

1 个答案:

答案 0 :(得分:0)

乍一看,有一行代码立即脱颖而出。我会改变

implementation "com.android.support.test.espresso.idling:idling-concurrent:3.0.2"

androidTestImplementation "com.android.support.test.espresso.idling:idling-concurrent:3.0.2"

因为Espresso旨在协助UI自动化测试。