Android Firebase UI 无法访问 aad



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

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

这是顶级构建.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-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. Openbuild.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 岁,这肯定会起作用

相关内容

  • 没有找到相关文章

最新更新