Как решить Google API совет, тип программы уже существует проблема? - PullRequest
3 голосов
/ 20 марта 2019

Я разрабатываю приложение для распознавания речи в Android.Использование API Google Cloud Speech и Firebase Cloudstore (для БД)

Когда я строю свой проект, я получаю следующую ошибку: *

Error: Program type already present: com.google.api.Advice$1

Я не знаю, как решить эту проблему

Мои шаги
Я искал в stackoverflow и обнаружил похожие проблемы, но не для моей проблемы, в частности

То есть я не знаю, какие пакеты мне нужныисключить для разрешения конфликта зависимостей

Пожалуйста, помогите мне

Мой Gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.google.cloud.examples.speechrecognition"
        minSdkVersion 23
        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'
        }
    }
    configurations {
        compile.exclude group: 'com.google.protobuf', module: 'protobuf-lite'

    }
    // exclude files that are not needed from the cloud client libraries
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/INDEX.LIST'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
// https://mvnrepository.com/artifact/io.grpc/grpc-grpclb
    compile group: 'io.grpc', name: 'grpc-grpclb', version: '1.19.0'

    // https://mvnrepository.com/artifact/io.grpc/grpc-auth
    compile group: 'io.grpc', name: 'grpc-auth', version: '1.19.0'

    // https://mvnrepository.com/artifact/io.grpc/grpc-alts
    compile group: 'io.grpc', name: 'grpc-alts', version: '1.19.0'
// https://mvnrepository.com/artifact/io.grpc/grpc-android
    compile group: 'io.grpc', name: 'grpc-android', version: '1.19.0'

    // add these dependencies for the speech client
    implementation 'io.grpc:grpc-okhttp:1.19.0'
    implementation 'com.google.cloud:google-cloud-speech:0.83.0-beta'

    implementation 'com.google.firebase:firebase-firestore:18.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

task copySecretKey(type: Copy) {
    File secretKey = file "$System.env.GOOGLE_APPLICATION_CREDENTIALS"
    from secretKey.getParent()
    include secretKey.getName()
    into 'src/main/res/raw'
    rename secretKey.getName(), "credential.json"
}
preBuild.dependsOn(copySecretKey)

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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