每次我尝试运行我的 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/