gpt4 book ai didi

Android程序类型已经存在错误

转载 作者:行者123 更新时间:2023-11-29 02:25:30 25 4
gpt4 key购买 nike

为了找到解决方案(他们提到 gradle 文件中重复的包名称、AndroidManifests 中的重复以及依赖版本不匹配),我经历了几个具有相同错误的线程,但没有一个与我的情况相同。这是我在构建应用程序时收到的错误消息:

Program type already present: ff.ecochallenges.game.BuildConfig
Message{kind=ERROR, text=Program type already present: ff.ecochallenges.game.BuildConfig, sources=[Unknown source file], tool name=Optional.of(D8)}

我的应用程序 gradle 文件如下所示:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "ff.ecochallenges"
minSdkVersion 21
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(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-firestore:17.1.0'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.firebaseui:firebase-ui-storage:0.6.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'
implementation 'com.inthecheesefactory.thecheeselibrary:stated-fragment-support-v4:0.9.1'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'com.github.varunest:sparkbutton:1.0.5'
implementation 'info.hoang8f:android-segmented:1.0.6'
implementation "com.android.support:support-compat:27.1.1"
implementation project(":garden-release")
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":game")
// Required for local unit tests (JUnit 4 framework)

// Required for instrumented tests
androidTestImplementation 'com.android.support:support-annotations:24.0.0'
androidTestImplementation 'com.android.support.test:runner:0.5'
}

apply plugin: 'com.google.gms.google-services'

我添加的新库(游戏)的 gradle 是这样的:

apply plugin: 'com.android.library'

android {
compileSdkVersion 27



defaultConfig {
minSdkVersion 21
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'
}
}
//[DO NOT REMOVE THE COMMENTED CODE BELOW!]
//////////////////////////////////////////////////////
afterEvaluate {
assembleDebug.finalizedBy(exportJar)
}
/////////////////////////////////////////////////////
//[DO NOT REMOVE THE COMMENTED CODE ABOVE!]

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.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'
}
//[DO NOT REMOVE THE COMMENTED CODE BELOW!]
///////////////////////////////////////////////////////////////////////////////////////////////////
task exportJar(type: Copy) {
from('build/intermediates/packaged-classes/debug/classes.jar')
include('classes.jar')
into('../garden/Assets/Plugins/Android')
rename('classes.jar', 'ecochallenges.jar')
}
task deleteOldJar(type: Delete) {
delete '../garden/Assets/Plugins/Android/ecochallenges.jar'
}
exportJar.dependsOn(deleteOldJar)
///////////////////////////////////////////////////////////////////////////////////////////////////
//[DO NOT REMOVE THE COMMENTED CODE ABOVE!]

当我在我的应用程序 gradle 中注释掉“implementation project(":game")”行时,它构建时没有错误,所以我确定“game”gradle 有问题,但我找不到它是什么。

最佳答案

其中一行可能定义 ff.ecochallenges.game 两次:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":garden-release")
implementation project(":game")

假设 libs 目录中包含一个 .jar

或模块 garden-release 可能依赖于模块 game

例如。你可以在模块 garden-release 中使用 api project(":game")

关于Android程序类型已经存在错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52481268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com