Android Studio | Google Play服务库依赖项错误

时间:2019-03-01 06:57:04

标签: android firebase

我正在创建一个使用Firebase和OpenTok的android应用程序。 我正在使用OpenTok在应用程序中启用视频通话。但是,当我同步我的项目时,gradle总是会引发错误。错误和应用gradle文件如下所述。

错误:

ERROR: In project 'app' a resolved Google Play services library dependency 
depends on another at an exact version (e.g. "[1.9,1
.99999]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

Dependency failing: com.tokbox:opentok-server-sdk:4.3.0 -> commons-codec:commons-codec@[1.9,1.99999], but commons-codec 
version was 1.12.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.tokbox:opentok-server-sdk@4.3.0
-- Project 'app' depends onto com.tokbox:opentok-server-sdk@{strictly 4.3.0}
-- Project 'app' depends onto commons-codec:commons-codec@{strictly 1.12}

For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
uild.gradle file.

build.gradle(应用程序:模块)

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

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.video1"
        minSdkVersion 20
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions{
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.opentok.android:opentok-android-sdk:2.15.3'
    implementation 'pub.devrel:easypermissions:2.0.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.tokbox:opentok-server-sdk:4.3.0'
    implementation group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.3.0'

    implementation 'com.google.firebase:firebase-firestore:18.0.1'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'

    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'
}

项目gradle文件:

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {

        classpath 'io.fabric.tools:gradle:1.25.4'
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com/' }
        maven { url "https://jitpack.io" }
        maven { url 'https://tokbox.bintray.com/maven' }
        flatDir {
            dirs 'libs'
        }
    }
}

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

1 个答案:

答案 0 :(得分:0)

请这样纠正:

顶级build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {

        classpath 'io.fabric.tools:gradle:1.25.4'
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com/' }
        maven { url "https://jitpack.io" }
        maven { url 'https://tokbox.bintray.com/maven' }
        flatDir {
            dirs 'libs'
        }
    }
}

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

app / build.gradle

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

  android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.video1"
        minSdkVersion 20
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions{
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }

    com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
}

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.opentok.android:opentok-android-sdk:2.15.3'
    implementation 'pub.devrel:easypermissions:2.0.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.3.0'

    implementation 'com.google.firebase:firebase-firestore:18.0.1'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'

    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'
}