错误:程序类型已存在:com.google.android.gms.internal.measurement.zzdz

时间:2018-11-10 13:30:26

标签: android kotlin

在Gradle构建期间出现此错误

  

错误:程序类型已存在:com.google.android.gms.internal.measurement.zzdz

     

我希望找到有关此错误的帮助   我的项目的Gradle文件   Gradle构建(Module:App)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 27
defaultConfig {
    vectorDrawables.useSupportLibrary = true
    applicationId "com.msk.obourschools"
    minSdkVersion 21
    targetSdkVersion 27
    versionCode 9
    versionName "1.0.7"
    testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner" 
    multiDexEnabled true
    //   kapt { generateStubs = true }

    }

    //   dexOptions { javaMaxHeapSize "4g" }

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),  'proguard-rules.pro'
    }
     }

   sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
    }

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
    abortOnError false
}

   configurations.all {
    //This is library is included with two different versions
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
  }
  }

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.anko:anko:0.10.4"
implementation 'com.android.support:multidex:1.0.3'
//noinspection GradleCompatible
implementation 'com.google.android.gms:play-services-ads:17.1.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'com.google.android:flexbox:1.1.0'
implementation 'com.iarcuschin:simpleratingbar:0.1.3'
implementation 'com.github.hotchemi:android-rate:1.0.1'


//login

//Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"


//Support
//noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation "com.android.support:appcompat-v7:$support_version"
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:appcompat- v7:$rootProject.ext.supportLibVersion"
implementation "com.android.support:support-v4:$rootProject.ext.supportLibVersion"
testImplementation 'com.android.support.test:runner:1.0.2'
testImplementation 'com.android.support.test.espresso:espresso- core:3.0.2'

//Firebase
implementation "com.google.firebase:firebase-firestore:17.1.3"
implementation "com.google.firebase:firebase-auth:16.0.5"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation 'com.google.firebase:firebase-config:16.1.0'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
implementation 'com.google.firebase:firebase-ads:17.1.0'
implementation  'com.google.firebase:firebase-analytics:16.0.5'
implementation  'com.google.firebase:firebase-appindexing:16.0.2'
implementation  'com.google.firebase:firebase-functions:16.1.3'
implementation  'com.crashlytics.sdk.android:crashlytics:2.9.6'
implementation  'com.google.firebase:firebase-invites:16.0.5'
implementation  'com.google.firebase:firebase-ml-model-interpreter:16.2.3'
implementation  'com.google.firebase:firebase-ml-vision:18.0.1'
implementation  'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
implementation  'com.google.firebase:firebase-perf:16.2.0'


//google services
implementation "com.google.android.gms:play-services-auth:16.0.1"
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.android.gms:play-services-tagmanager:16.0.5"


//Mini
implementation 'com.github.pabloogc:Mini:1.0.1'
annotationProcessor 'com.github.pabloogc.Mini:mini-processor:1.0.1'

//Dagger
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"

//Rx
implementation "io.reactivex.rxjava2:rxjava:$rx_version"
implementation "io.reactivex.rxjava2:rxandroid:$rx_android_version"
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'

//Test
testImplementation 'junit:junit:4.12'
testImplementation 'com.natpryce:hamkrest:1.4.2.0'
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testImplementation 'org.junit.platform:junit-platform-runner:1.0.1'
testImplementation "junit:junit:$rootProject.ext.junitVersion"

//Guava
implementation 'com.google.guava:guava:27.0-jre'
// or, for Android:
api 'com.google.guava:guava:27.0-android'

}

repositories {
mavenCentral()
maven { url "http://dl.bintray.com/jetbrains/spek" }
}
 apply plugin: 'com.google.gms.google-services'
  

Gradle Build(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
    kotlin_version = '1.2.51'
    espressoVersion = '3.0.1'
    junitVersion = '4.12'
    supportLibVersion = '27.0.2'
    supportTestVersion = '1.0.1'
    //login
    gson_version = "2.8.2"
    dagger_version = "2.15"
    rx_version = "2.1.8"
    glide_version = "4.7.1"
    rx_firebase_version = "1.1.3"
    support_version = "27.1.1"
    rx_android_version = "2.0.2"
    target_sdk_version = 27
    googlePlayServicesVersion = "16.0.1"

    }
   repositories {
    google()
    maven {
        url 'https://dl.google.com/dl/android/maven2'
    }
    maven { url 'http://raw.github.com/saki4510t/libcommon/master /repository/' }
    jcenter()
    maven { url "https://jitpack.io" }
    maven { url "https://maven.fabric.io/public" }
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.0.1'
    classpath 'io.fabric.tools:gradle:1.25.4'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }


    }

   allprojects {
   repositories {
    mavenCentral()
    maven { url "http://dl.bintray.com/jetbrains/spek" }
    maven { url "https://jitpack.io" }
    google()
    jcenter()
    maven {
        url "https://maven.google.com" // Google's Maven repository
    }

    configurations.all {
        resolutionStrategy {
            // react-native-google-analytics-bridge
            force "com.google.android.gms:play-services-analytics:16.0.1"
            force "com.google.android.gms:play-services-tagmanager-v4-impl:16.0.1"
            // react-native-device-info
            force "com.google.android.gms:play-services-gcm:15.0.0"
          }
        }

     }
     }

   task clean(type: Delete) {
    delete rootProject.buildDir
    }

我尝试了所有解决方案,但错误仍然出现并更新了所有Firebase和Google库,并且没有新的

1 个答案:

答案 0 :(得分:0)

在您的应用程序级别gradle文件降级

download_required_files

implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-firestore:17.1.3"
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-ads:17.1.0'
implementation  'com.google.firebase:firebase-functions:16.1.3'
implementation  'com.crashlytics.sdk.android:crashlytics:2.9.6'
implementation  'com.google.firebase:firebase-invites:16.0.5'

已弃用项目中的 implementation 'com.google.firebase:firebase-core:16.0.4' implementation 'com.google.firebase:firebase-firestore:17.1.2' implementation 'com.google.firebase:firebase-database:16.0.4' implementation 'com.google.firebase:firebase-storage:16.0.4' implementation 'com.google.firebase:firebase-ads:17.0.0' implementation 'com.google.firebase:firebase-functions:16.1.2' implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5' implementation 'com.google.firebase:firebase-invites:16.0.4'

并删除implementation 'com.google.firebase:firebase-crash:16.2.1',因为它是implementation 'com.google.firebase:firebase-analytics:16.0.5'的别名

在您的项目级别gradle文件中更新

implementation 'com.google.firebase:firebase-core:16.0.4'

收件人

classpath 'com.google.gms:google-services:4.0.1'