I'm developing an Android app that involves authenticating the user using the GoogleApiClientBuilder class. The error occurs during runtime when I hit this part of my code:
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN);
This works perfectly fine on Android 5.0.1 but when I try it on API level 19 (Kitkat), I get this error:
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)
After doingh some research I found it may have been Proguard stripping away the necessary classes but whether I enable or disable minifyEnabled, it doesn't work:
buildTypes {
release {
minifyEnabled = true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Then I did some more research and figured maybe it as a multiDex issue but I enabled it and I'm even compiling it as one of my dependencies
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'
}
So as of no it only works on Lollipop but nothing lower than that.. Please help me if you can!