程序类型已存在:android.support.v4.app.BackStackRecord

Kur*_*ara 54 android build.gradle

我升级了我的android工作室..我在最新版本中发现了很多问题

虽然存在许多类似的问题,但我检查了所有答案,但没有一个对我有效!

这是编译代码时我遇到的错误:

程序类型已存在:android.support.v4.app.BackStackRecord $ Op Message {kind = ERROR,text =程序类型已存在:android.support.v4.app.BackStackRecord $ Op,sources = [未知源文件],工具命名= Optional.of(D8)}

这是我的gradle文件

项目:

// Top-level build file where you can add configuration options common to 

all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'


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

 allprojects {
 repositories {
    google()
    jcenter()
    maven {
        url "https://jitpack.io"
          }
     }
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

应用:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.alcantara.bugismart"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    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'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso- 
    core:3.0.1'
    implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
}
Run Code Online (Sandbox Code Playgroud)

你可以告诉我是否还有其他东西需要补充,以了解我在做什么或我错在哪里.

ישו*_*ותך 86

问题可能是因为重复的支持库.这种依赖:

implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
Run Code Online (Sandbox Code Playgroud)

正在使用旧版本的支持库.尝试将支持库排除在:

// support libraries we want to use
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'

// we already have the specific support libraries. So, exclude it
implementation ('com.github.ViksaaSkool:AwesomeSplash:v1.0.0') {    
    exclude group: 'com.android.support'
    exclude module: 'appcompat-v7'
    exclude module: 'support-v4'
}
Run Code Online (Sandbox Code Playgroud)

您需要使用以下命令检查依赖项:

./gradlew app:dependencies
Run Code Online (Sandbox Code Playgroud)


小智 37

在build.gradle中添加它(模块:app)

build.gradle


TmT*_*ron 10

接受答案的另一种方法是告诉gradle强制推出更新的版本:

final SUPPORT_LIB_VER = '27.1.1'

configurations.all {
    resolutionStrategy { 
        force "com.android.support:appcompat-v7:${SUPPORT_LIB_VER}"
        force "com.android.support:support-v4:${SUPPORT_LIB_VER}"
    }
}
Run Code Online (Sandbox Code Playgroud)

当您有许多依赖项时,这可能更方便.

另请参阅:回答"我如何强制Gradle为两个依赖项设置相同的版本?"


小智 9

在Gradle文件的依赖项部分添加此代码行

implementation 'com.android.support:support-v4:28.0.0'
Run Code Online (Sandbox Code Playgroud)