首页 > 解决方案 > 原因:java.lang.ClassNotFoundException:在路径上找不到类“com.google.android.gms.common.internal.zzbq”

问题描述

我在构建项目时遇到了这个问题。我无法通过更新播放服务来解决16.0.015.0.0

错误如下:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file]]

项目级 build.gradle

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

buildscript {

    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        //classpath 'com.google.gms:google-services:3.2.1'
        classpath 'com.google.gms:google-services:4.0.1'


        // google-services plugin


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

allprojects {
    repositories {
        google()
        jcenter()

    }
}


ext {
    library_play_service_version = '12.0.1'
}


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

应用级 build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "in.greylabs.beacondriver"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 5
        versionName "1.0.4"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

afterEvaluate {
    tasks.matching {
        it.name.startsWith('dex')
    }.each { dx ->
        if (dx.additionalParameters == null) {
            dx.additionalParameters = ['--multi-dex']
        } else {
            dx.additionalParameters += '--multi-dex'
        }
    }
}

repositories {
    maven {
        url "http://hypertrack-android-sdk.s3-website-us-west-2.amazonaws.com/"
    }
    maven { url 'https://maven.google.com' }
    maven { url 'https://maven.fabric.io/public' }
}

ext {
    supportVersion = '27.1.1'
    playServicesVersion = '12.0.1'
    butterKnifeVersion = '8.8.1'
    glideVersion = '3.7.0'
}




dependencies {
    //noinspection GradleCompatible
    implementation 'com.android.support:support-v4:26.1.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //HyperTrack: HyperTrack library
    implementation('com.hypertrack:android:0.7.16@aar') {
        transitive = true;
    }
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    //noinspection UseOfBundledGooglePlayServices
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.google.android.gms:play-services-analytics:16.0.0'
    implementation "com.google.firebase:firebase-core:16.0.0"

    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
    implementation 'com.squareup.okhttp3:okhttp:3.9.0'
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    implementation 'jp.wasabeef:glide-transformations:3.0.1'
    testImplementation 'junit:junit:4.12'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
    implementation( 'com.crashlytics.sdk.android:crashlytics:2.7.1@aar' ) {
        transitive = true
    }
}
apply plugin: 'com.google.gms.google-services'

标签: androidgoogle-play-serviceshypertrack

解决方案


这是因为您有多个版本的 Google Play 服务,它们具有以下依赖项:

implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.0'

因此,您需要删除以下内容:

implementation 'com.google.android.gms:play-services:12.0.1'

并且只使用一个版本的库:

implementation 'com.google.android.gms:play-services-analytics:12.0.1' 
implementation 'com.google.firebase:firebase-core:12.0.1'

请记住,您通过添加上述依赖项来添加整个 Play 服务。您应该只使用您想要的库。阅读更多https://developers.google.com/android/guides/setup


推荐阅读