程序类型已存在 - 错误

时间:2018-06-18 06:14:18

标签: android gradle runtime-error

尝试运行我的应用时出现此错误 - 程序类型已存在:android.support.v4.app.BackStackRecord $ Op

我已经通过了帖子 - Program type already present: android.support.v4.app.BackStackRecord但仍然无法解决问题,下面是我的gradle文件供参考 -

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.google"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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'
    implementation 'com.google.android.gms:play-services:9.4.0'
//    // retrofit, gson
    implementation 'com.google.code.gson:gson:2.6.2'
    implementation 'com.squareup.retrofit2:retrofit:2.0.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.0.2'

}

2 个答案:

答案 0 :(得分:0)

尝试更改apply plugin: 'com.android.application'和/或applicationId "com.google"

答案 1 :(得分:0)

检查您的项目级别gradle文件,如下所示..

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.41'

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

也尝试检查这一行。

implementation 'com.android.support:appcompat-v7:27.0.2'