android - 程序类型已经存在 : android. support.v4.app.BackStackRecord$Op

标签 android

每次我尝试运行我的 Android 游戏时都会遇到此错误:

Program type already present: android.support.v4.app.BackStackRecord$Op
Message{kind=ERROR, text=Program type already present: android.support.v4.app.BackStackRecord$Op, sources=[Unknown source file], tool name=Optional.of(D8)}

这是我的build.gradle (app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.play.flyaway"
        minSdkVersion 21
        targetSdkVersion 27

        ndk {
            moduleName "player_shared"
        }
    }
    sourceSets {
        main {
            jni.srcDirs = []
        }
    }
    buildTypes{}
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation files('libs/dagger-1.2.2.jar')
    implementation files('libs/javax.inject-1.jar')
    implementation files('libs/nineoldandroids-2.4.0.jar')
    implementation files('libs/support-v4-19.0.1.jar')
}

build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
    }
}

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

这个问题有什么解决办法吗?当然,我已经尝试了所有我知道的方法,但我是新手,除了控制台显示的内容之外,我真的不知道是什么原因导致错误

最佳答案

您需要删除以下依赖项:

implementation files('libs/support-v4-19.0.1.jar')

同时从 libs 目录中删除 jar。然后使用你的compileSdkVersion配套的支持库。因此,将上述依赖项更改为:

implementation 'com.android.support:support-v4:27.1.1'

这与 Google play service dependency 有关:

SDK Version Support in 11.2

When you upgrade your app’s Play services dependencies to 11.2.0 or later, your app’s build.gradle must also be updated to specify a compileSdkVersion of at least 26 (Android O). This does not change the way your app runs. You will not be required to update targetSdkVersion.

关于android - 程序类型已经存在 : android. support.v4.app.BackStackRecord$Op,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49917614/

相关文章:

Android Studio 和 Gradle 一起生活?

android - 如何(以编程方式)更改 EditText 上气泡(光标下)的颜色?

android - Android Loader 中 onCanceled() 的用途是什么

android - ActionBarActivity 后退按钮到 fragment

Android Studio Gradle 产品 flavor

android - AdMob - InterstitialAd 未在真实设备上显示

android - 如何在phonegap中实现推送通知

android - eclipse : Gluon mobile charm down VideoService - not found

android - 在 LinearLayout 中的现有 fragment 下方动态添加 fragment

java - 我需要以 2 分钟的间隔执行 AsynckTask 对象 5 次