我的Google登录正在运行然后我必须将Google Play服务auth库从10.升级到11.2.0然后它在我运行应用程序时开始给我这个错误
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,但它仍然崩溃。我没有找到关于google play auth这个错误的更多信息,但是当使用react和android native时它似乎很安静。
错误指定的代码行是 -
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:2.1.0@aar') {
transitive = true;
}
compile('com.digits.sdk.android:digits:2.0.4@aar') {
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 :(得分: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
// ...
}
}
}
答案 1 :(得分:0)
此信息可能有所帮助。 Google Play服务版本11.2.0发生了一些变化。您的应用的compileSdkVersion必须至少为26。
您可以在此处阅读更多内容How to run an EXE file in PowerShell with parameters with spaces and quotes。
查看您的compileSdkVersion
设置为25.尝试将其更改为26。
答案 2 :(得分:0)
我只需要清理和构建我的项目并且它有效......我没有改变任何东西......感谢Sahil和Noogui的答案都是一样的。