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大佬告诉我,他还没有最新的,好吧,楼上的方案还是暂行可以的


MAVEN runner
MAVEN espresso-core
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 179,323评论 25 708
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    wgl0419阅读 6,602评论 1 9
  • 这家餐馆店名简单,以老板儿子之名“小荣”所命名,据说刚开始的时候生意并不好,因为地理位置偏远,需要当地人引路才可以...
    郭懿德阅读 665评论 0 0
  • 窗角的葫芦籽放了好几年了,进雨后竟然发芽了,,心里异常的感动,不为那点嫩绿,而是那份坚持和隐忍,抱着对生命的执着和...
    老悠阅读 201评论 0 0

友情链接更多精彩内容