如何将 Firebase 和 Snap Creative Kit 作为 Gradle 依赖项包含在内



我尝试在我的安卓项目中使用 Snap 创意工具包,该项目已经在使用 Firebase,但由于此错误而无法构建:

Program type already present: com.google.protobuf.Any$1

Firebase Firestore 使用protobuf-lite,而 Snap Creative Kit 使用protobuf-java。我试图从 Firestore 中排除protobuf-lite,但错误仍然存在。当我也从 Firestore 中排除com.google.firebase:protolite-well-known-types时,项目会生成但崩溃。

build.gradle (Project(

buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'io.fabric.tools:gradle:1.25.4'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://storage.googleapis.com/snap-kit-build/maven"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

build.gradle (Module:app(

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.snapchat.kit.sdk:creative:1.0.2'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-firestore:17.1.0'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation 'com.google.firebase:firebase-ml-model-interpreter:16.2.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
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'
}

问题解决了,最新版本的 Creative Kit 解决了这个问题。只需更改

implementation 'com.snapchat.kit.sdk:creative:1.0.2'

implementation 'com.snapchat.kit.sdk:creative:1.1.3'

最新更新