2017-08-24 98 views
0

我的谷歌登錄工作,然後我不得不將谷歌播放服務auth庫從10.升級到11.2.0,然後它開始給我這個錯誤當我運行的應用程序應用程序崩潰,錯誤 - java.lang.AbstractMethodError升級到gms後:play-services 11

java.lang.AbstractMethodError: abstract method "com.google.android.gms.common.api.Api$zze com.google.android.gms.common.api.Api$zza.zza(android.content.Context, android.os.Looper, com.google.android.gms.common.internal.zzq, java.lang.Object, com.google.android.gms.common.api.GoogleApiClient$ConnectionCallbacks, com.google.android.gms.common.api.GoogleApiClient$OnConnectionFailedListener)" 
                     at com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown Source) 
                     at com.dishesteam.dishes.activities.LoginActivity.onCreate(LoginActivity.java:138) 
                     at android.app.Activity.performCreate(Activity.java:6609) 
                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134) 
                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3113) 
                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3275) 
                     at android.app.ActivityThread.access$1000(ActivityThread.java:218) 
                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1744) 
                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                     at android.os.Looper.loop(Looper.java:145) 
                     at android.app.ActivityThread.main(ActivityThread.java:7007) 
                     at java.lang.reflect.Method.invoke(Native Method) 
                     at java.lang.reflect.Method.invoke(Method.java:372) 
                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 

我把庫退回到11.0.4,但它仍然崩潰。我沒有找到有關谷歌播放auth這個錯誤的很多信息,但它似乎是安靜的常見,同時使用反應和Android本機。

的,錯誤指定代碼行是 -

mGoogleApiClient = new GoogleApiClient.Builder(this) 
      .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) 
      .addApi(Auth.GOOGLE_SIGN_IN_API,gso) 
      .build(); 

我的build.gradle文件看起來像這樣 -

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

dependencies { 
    classpath 'io.fabric.tools:gradle:1.22.0' 
} 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
apply plugin: 'com.jakewharton.butterknife' 

repositories { 
    maven { url 'https://maven.fabric.io/public' } 
    maven { 
    url "https://maven.google.com" 
    } 
} 
android { 

compileSdkVersion 25 
buildToolsVersion "25.0.2" 
dexOptions { 
    javaMaxHeapSize "4g" 
} 
defaultConfig { 
    applicationId "com.dishesteam.dishes" 
    minSdkVersion 16 
    targetSdkVersion 25 
    versionCode 4 
    versionName "1.0" 
    vectorDrawables.useSupportLibrary = true 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    signingConfig signingConfigs.config 
    multiDexEnabled true 
    jackOptions { 
     enabled true 
    } 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     signingConfig signingConfigs.config 
    } 
    debug { 
     debuggable true 
    } 
} 
productFlavors { 
} 
compileOptions { 
    targetCompatibility 1.8 
    sourceCompatibility 1.8 
} 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
compile('com.twitter.sdk.android:twitter:[email protected]') { 
    transitive = true; 
} 
compile('com.digits.sdk.android:digits:[email protected]') { 
    transitive = true; 
} 
compile('com.google.api-client:google-api-client-android:1.22.0') { 
    exclude group: 'org.apache.httpcomponents' 
} 
compile('com.google.apis:google-api-services-youtube:v3-rev183-1.22.0') { 
    exclude group: 'org.apache.httpcomponents' 
} 
compile files('libs/PhotoUtil.jar') 
compile 'pub.devrel:easypermissions:0.3.0' 
compile 'com.android.support:multidex:1.0.1' 
compile 'com.android.support:appcompat-v7:25.2.0' 
compile 'com.android.support:cardview-v7:25.2.0' 
compile 'com.android.support:design:25.2.0' 
compile 'com.android.support:support-v4:25.2.0' 
compile 'com.android.support:support-vector-drawable:25.2.0' 
compile 'org.greenrobot:eventbus:3.0.0' 
compile 'com.google.code.gson:gson:2.7' 
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' 
compile 'io.reactivex:rxandroid:1.2.0' 
compile 'io.reactivex:rxjava:1.1.8' 
compile 'com.squareup.retrofit2:retrofit:2.1.0' 
compile 'com.squareup.retrofit2:converter-gson:2.1.0' 
compile 'com.squareup.okhttp3:okhttp:3.4.1' 
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' 
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' 
compile 'com.android.support:preference-v7:25.2.0' 
compile 'com.android.support:recyclerview-v7:25.2.0' 
compile 'de.hdodenhof:circleimageview:2.1.0' 
compile 'com.github.bumptech.glide:glide:3.7.0' 
compile 'com.jakewharton:butterknife:8.6.0' 
compile 'com.google.android.gms:play-services-auth:11.0.4' 
compile 'com.google.android.gms:play-services-location:11.0.4' 
compile 'com.google.android.gms:play-services-base:11.0.4' 
compile 'com.google.firebase:firebase-messaging:10.0.1' 
testCompile 'junit:junit:4.12' 
androidTestCompile 'junit:junit:4.12' 
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0' 
} 

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

回答

0

我也有相同的配置11.0.4,它是工作精細。這是我的代碼:

mGoogleApiClient = new GoogleApiClient.Builder(this) 
       .enableAutoManage(this /* FragmentActivity */, new GoogleApiClient.OnConnectionFailedListener() { 
        @Override 
        public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { 
         Toast.makeText(MainActivity.this, "Google Play Services error.", Toast.LENGTH_SHORT).show(); 
        } 
       }/* OnConnectionFailedListener */) 
       .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
       .build(); 

後來調用以下函數

Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); 
startActivityForResult(signInIntent, RC_SIGN_IN); 

startActivityForResult

@Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 

     // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); 
     if (requestCode == RC_SIGN_IN) { 
      GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); 
      if (result.isSuccess()) { 
       // Google Sign In was successful, authenticate with Firebase 
       GoogleSignInAccount account = result.getSignInAccount(); 
       progress = new ProgressDialog(this); 
       progress.setMessage("Connecting Please Wait!.."); 
       progress.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
       progress.setIndeterminate(true); 
       progress.show(); 
       firebaseAuthWithGoogle(account); 
      } else { 
       // Google Sign In failed, update UI appropriately 
       // ... 
      } 
     } 
    } 
+0

不知道我的配置有什麼問題.....你用的是什麼谷歌播放庫? –

+0

這些是庫: compile'c​​om.google.firebase:firebase-auth:11.0.4' compile'c​​om.google.android.gms:play-services-auth:11.0.4' – Sahil

0

此信息可能會有幫助。 Google Play服務版本11.2.0發生了一些變化。您的應用的compileSdkVersion必須至少爲26.

您可以在此處閱讀更多內容Some Updates to Apps Using Google Play services。你compileSdkVersion

尋找它設置爲25。嘗試改變,爲26

0

我只是不得不清理並生成我的項目,它的工作...我沒有改變什麼......由於薩赫勒和Noogui他們的答案都一樣。