gpt4 book ai didi

Android Studio 提示重复类

转载 作者:行者123 更新时间:2023-12-04 23:51:03 25 4
gpt4 key购买 nike

我正在尝试生成一个 apk 文件,但 android studio 向我显示以下错误:

Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient found in modules classes.jar (com.google.android.gms:play-services-ads-identifier:17.0.0) and classes.jar (com.google.android.gms:play-services-analytics:7.8.0) Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info found in modules classes.jar (com.google.android.gms:play-services-ads-identifier:17.0.0) and classes.jar (com.google.android.gms:play-services-analytics:7.8.0) Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient$zza found in modules classes.jar (com.google.android.gms:play-services-ads-identifier:17.0.0) and classes.jar (com.google.android.gms:play-services-analytics:7.8.0)



它以前工作过。我完全没有对代码进行任何更改。任何人都可以帮忙吗?

这是我的 build.gradle 文件:
apply plugin: "com.android.application"

import com.android.build.OutputFile

def jscFlavor = 'org.webkit:android-jsc:+'


def enableHermes = project.ext.react.get("enableHermes", false);

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.step_by_step.virq"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}

}
}
}

dependencies {
implementation project(':react-native-push-notification')
implementation project(':react-native-firebase')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:17.0.1"
implementation "com.google.firebase:firebase-messaging:19.0.1"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
implementation "com.google.android.gms:play-services:7.8.0"

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}

task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-
android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: "com.google.gms.google-services"

最佳答案

你的版本 [ 7.8.0 ] 的 play-services-analytics很老了。尝试使用最新的

implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.gms:play-services-ads:18.3.0'

关于Android Studio 提示重复类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59553838/

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