繁体   English   中英

Android Firebase UI无法访问AAD

[英]Android Firebase UI cannot access aad

我要运行我的应用程序时遇到以下错误: 无法访问com.google.android.gms.internal.aad的aad类文件

我想这将是一个build.gradle问题。 但是,我的构建文件中似乎找不到任何内容。

这是顶层build.gradle

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.google.gms:google-services:3.1.0'
}
}

allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
}

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

这是应用程序级别的build.grade:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.somesite.foo"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    resConfigs "auto"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
compile('com.facebook.android:facebook-android-sdk:4.22.1')
}

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

这是试图使一切开始的活动:

protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.SplashTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    FirebaseAuth auth = FirebaseAuth.getInstance();
    if (auth.getCurrentUser() != null)
    {
        // already signed in
        auth.signOut();
    }
    else
    {
        //AuthU
        // not signed in
        startActivityForResult(
                AuthUI.getInstance()
                        .createSignInIntentBuilder()
                        .setIsSmartLockEnabled(false)
                        .setAvailableProviders(
                                Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                        new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                                        new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
                        .build(),
                RC_SIGN_IN);
    }

}

该问题很可能是由于firebase-ui-auth:2.3.0firebase-core:11.2.0不兼容引起的。 最简单的修复是将其降级到与firebase firebase-ui-auth:2.3.0兼容的版本11.0.4:

compile 'com.google.firebase:firebase-core:11.0.4' // CHANGED
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
compile('com.facebook.android:facebook-android-sdk:4.22.1')

如果要坚持使用11.2.0,则可以通过以下更改将2.3.0升级为使用11.2.0版:

compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0' // ADDED
compile 'com.google.android.gms:play-services-auth:11.2.0' // ADDED
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
compile('com.facebook.android:facebook-android-sdk:4.22.1')

有关库版本兼容性的说明,请参阅FirebaseUI文档

当您的依赖项具有混合版本或不合适的版本时,会发生此错误

要解决此问题,请使用以下步骤:

  1. 打开build.gradle
  2. 使用以下依赖项:

     implementation 'com.google.firebase:firebase-auth:11.8.0' implementation 'com.google.firebase:firebase-database:11.8.0' implementation 'com.google.firebase:firebase-storage:11.8.0' implementation 'com.android.support:support-v4:27.1.0' implementation 'com.firebaseui:firebase-ui-database:3.2.2' 
  3. 确保您不重复任何依赖项

  4. 单击同步

如果您的compileSdkVersiontargetSdkVersion为27,则绝对可以

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM