java.lang.NoClassDefFoundError:com.google.android.gms.internal.zzpt $ zza

时间:2015-07-03 17:34:20

标签: java android google-play-services classnotfoundexception google-api-client

我开发的Android应用程序涉及使用GoogleApiClientBuilder类对用户进行身份验证。当我点击我的代码的这部分时,错误发生在运行时:

GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN);

这在Android 5.0.1上完全正常,但是当我在API级别19(Kitkat)上尝试时,我收到此错误:

java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzpt$zza
        at com.google.android.gms.common.api.GoogleApiClient$Builder.<init>(Unknown Source)
        at com.tubealert.tubealert.Splash.buildGoogleApiClient(Splash.java:58)
        at com.tubealert.tubealert.Splash.onCreate(Splash.java:45)
        at android.app.Activity.performCreate(Activity.java:5231)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
        at android.app.ActivityThread.access$800(ActivityThread.java:135)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5001)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
        at dalvik.system.NativeStart.main(Native Method)

在做了一些研究后,我发现它可能是Proguard剥离了必要的类,但无论我是启用还是禁用minifyEnabled,它都不起作用:

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

然后我做了一些更多的研究,并认为它可能是一个multiDex问题,但我启用了它,我甚至将它编译为我的依赖项之一

defaultConfig {
    applicationId "com.tubealert.tubealert"
    minSdkVersion 17
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled = true
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    configurations { all*.exclude group: 'com.google.guava', module: 'guava' }
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:cardview-v7:21.0.0'
    compile 'com.android.support:recyclerview-v7:22.+'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.google.apis:google-api-services-youtube:v3-rev134-1.20.0'
    compile 'com.google.gdata:core:1.47.1'
}

所以不,它只适用于棒棒糖但不低于此......如果可以,请帮助我!

2 个答案:

答案 0 :(得分:0)

尝试为Google API添加模糊规则: ProGuard Configuration

答案 1 :(得分:-5)

想出来。只需按照设置谷歌播放服务的每一步!我的愚蠢错误。