Program type already present: android.support.v4.app.backstackrecord$Op

默认格式下生成project,编译出现
Program type already present: android.support.v4.app.backstackrecord$Op

//TODO other...
compileSdkVersion 28
    defaultConfig {
        applicationId "com.changan.facein"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "v1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

//TODO other...

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:28.0.0-alpha3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

后来去查阅Google官网和论坛,发现只要把API等级从28改成27以下就可以完美解决。代码如下

//TODO other...
 compileSdkVersion 27
    defaultConfig {
        applicationId "com.changan.facein"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "v1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

//TODO other...

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

作为一个作死的程序员,一定要搞懂为嘛会出现这个情况。然后再查阅一批资料和跟大神不断交流中得出,

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
这两兄弟最多支持到API27,到28跑不过人家了,然后这里就得出另一个解决方案,把这两兄弟的版本提升也是可以的。然而Maven大佬告诉我,他还没有最新的,好吧,楼上的方案还是暂行可以的


Program type already present: android.support.v4.app.backstackrecord$Op_第1张图片
MAVEN runner
Program type already present: android.support.v4.app.backstackrecord$Op_第2张图片
MAVEN espresso-core

你可能感兴趣的:(Program type already present: android.support.v4.app.backstackrecord$Op)