Android Firebase用户界面无法访问aad

时间:2017-08-28 03:19:53

标签: java android firebase gradle firebaseui

当我去运行我的应用时,我遇到以下错误:无法访问aad 找不到com.google.android.gms.internal.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
}

这是app level 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);
    }

}

2 个答案:

答案 0 :(得分:3)

问题可能是firebase-ui-auth:2.3.0firebase-core:11.2.0不兼容造成的。最简单的解决方法是降级到11.0.4,与firebase-ui-auth:2.3.0兼容的版本:

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 documentation

答案 1 :(得分:1)

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

要解决此问题,请执行以下步骤:

  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. 点击 SYNC

如果您的compileSdkVersiontargetSdkVersion都是27岁,那么这肯定会起作用