【问题标题】:Program type already present - ERROR程序类型已存在 - 错误
【发布时间】:2018-06-18 06:14:17
【问题描述】:

尝试运行我的应用时出现此错误 - 程序类型已存在: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'

}

【问题讨论】:

标签: android gradle runtime-error


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    检查您的项目级 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'
    

    【讨论】:

      猜你喜欢
      • 2019-07-25
      • 2019-09-04
      • 2020-10-13
      • 2019-05-22
      • 2020-03-26
      • 2019-05-03
      • 2018-09-07
      • 2020-02-15
      • 1970-01-01
      相关资源
      最近更新 更多