使用自己的身份验证服务器复制 firebase-auth 模块和 firebase-common-auth

Posted

技术标签:

【中文标题】使用自己的身份验证服务器复制 firebase-auth 模块和 firebase-common-auth【英文标题】:duplication of firebase-auth module and firebase-common-auth using own authentication server 【发布时间】:2020-09-06 12:44:29 【问题描述】:

我正在使用 Google、Facebook 和自定义服务器身份验证方法, 我使用 Twillio 消息传递 API 进行电话号码验证。

现在我想使用 Firebase 短信验证,但我无法使用 com.google.firebase:firebase-auth:19.3. 依赖项来调用方法 PhoneAuthProvider 谁能帮我指导一下?

使用 firebase-auth 依赖项在构建过程中显示此重复错误:

Gradle:

Duplicate class com.google.firebase.auth.AuthCredential found in modules jetified-firebase-auth- 
19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common- 
9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.EmailAuthCredential found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.EmailAuthProvider found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.FacebookAuthCredential found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.FacebookAuthProvider found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.FirebaseAuthProvider found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.GithubAuthCredential found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.GithubAuthProvider found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.GoogleAuthCredential found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.GoogleAuthProvider found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.TwitterAuthCredential found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.TwitterAuthProvider found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.UserInfo found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.UserProfileChangeRequest found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.UserProfileChangeRequest$Builder found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1)
Duplicate class com.google.firebase.auth.zza found in modules jetified-firebase-auth-19.3.1-runtime.jar (com.google.firebase:firebase-auth:19.3.1) and jetified-firebase-auth-common-9.6.1-runtime.jar (com.google.firebase:firebase-auth-common:9.6.1) 
Go to the documentation to learn how to Fix dependency resolution errors

gradle.build(project) 依赖是

 dependencies 
        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    

gradle.build(应用级)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
buildscript 
    repositories 
        maven  url 'https://maven.fabric.io/public' 
    

    dependencies 
        classpath 'io.fabric.tools:gradle:1.+'
    

repositories 
    maven  url 'https://maven.fabric.io/public' 


android 

    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false
    buildToolsVersion

    defaultConfig 
        applicationId "com.orderdoo.customer"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    

    lintOptions 
        checkReleaseBuilds false
        abortOnError false;
        disable 'deprecation'
    

    dexOptions 
        javaMaxHeapSize "4g"
        jumboMode true
    


    buildTypes 
        release 
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        
    

    compileOptions 
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    

    allprojects 

        tasks.withType(JavaCompile) 
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        


        repositories 
            mavenCentral()
            mavenLocal()
            jcenter()
            google()
            maven  url "https://jitpack.io" 
            maven  url "https://s3.amazonaws.com/repo.commonsware.com" 
            maven 
                url "https://maven.google.com"
            

        

        packagingOptions 
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
            exclude 'META-INF/services/javax.annotation.processing.Processor'
        

    




dependencies 
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation('com.squareup.retrofit2:converter-simplexml:2.3.0') 
        exclude group: 'xpp3', module: 'xpp3'
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'stax', module: 'stax'
    
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.bartoszlipinski:recyclerviewheader2:2.0.1'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
    implementation 'com.github.markushi:circlebutton:1.1'
    implementation 'androidx.multidex:multidex:2.0.0'
    implementation 'com.github.arimorty:floatingsearchview:2.1.1'
    implementation 'com.romandanylyk:pageindicatorview:0.2.0'

    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.github.reinaldoarrosi:maskededittext:1.1.0'
    implementation 'com.facebook.android:facebook-login:[5,6)'
    implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
    implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
    implementation 'com.hedgehog.ratingbar:app:1.1.2'
    implementation 'uk.co.ribot:easyadapter:1.5.0@aar'
    implementation 'com.github.rahimlis:badgedtablayout:v1.2'
    implementation 'com.kaopiz:kprogresshud:1.1.0'
    implementation 'com.gmail.samehadar:iosdialog:1.0'
    implementation 'com.github.jd-alexander:library:1.1.0'
    implementation 'com.facebook.fresco:fresco:2.0.0'


    implementation "com.google.firebase:firebase-core:16.0.4"
    implementation 'com.google.firebase:firebase-database:19.3.0'
    implementation 'com.google.firebase:firebase-messaging:20.1.7'
    implementation 'com.google.firebase:firebase-auth:19.3.1' //this generates duplication

    implementation 'com.google.android.gms:play-services-gcm:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'

    implementation 'com.github.ar-android:DrawRouteMaps:1.0.0'

    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'in.srain.cube:ultra-ptr:1.0.11'

    implementation 'com.code-troopers.betterpickers:library:3.1.0'
    implementation 'com.miguelcatalan:materialsearchview:1.4.0'

    implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'

    implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') 
        transitive = true;
    


    implementation 'org.jetbrains:annotations:15.0'



apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

【问题讨论】:

【参考方案1】:

尝试执行此命令,因为在终端中使用以下命令运行构建很有用:

./gradlew --info assembleDebug

因为这将帮助您找出涉及冲突的所有依赖项的完整列表:

依赖关系解析帮助:显示所有当前已知路径到任何版本的依赖关系:Artifact(groupId=com.google.firebase, artifactId=firebase-iid)

-- task/module dep -> firebase-analytics@17.2.0
---- firebase-analytics:17.2.0 library depends -> play-services-measurement-api@17.2.0
------ play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0

-- task/module dep -> firebase-core@17.2.0
---- firebase-core:17.2.0 library depends -> firebase-analytics@17.2.0
------ firebase-analytics:17.2.0 library depends -> play-services-measurement-api@17.2.0
-------- play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0

-- task/module dep -> play-services-measurement-api@17.2.0
---- play-services-measurement-api:17.2.0 library depends -> firebase-iid@19.0.0

-- task/module dep -> firebase-iid@19.0.0

-- task/module dep -> firebase-messaging@17.1.0
---- firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]

-- task/module dep -> com.pressenger:sdk@4.8.0
---- com.pressenger:sdk:4.8.0 library depends -> firebase-messaging@17.1.0
------ firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]

从这份清单中,您将了解 2 件事:

冲突依赖在哪里以及冲突依赖的版本是什么。

在这种情况下,冲突的依赖是 firebase-iid:它是 @19.0.0 或 @16.2.0

要解决此问题,您必须在 build.gradle 中明确定义错误 firebase-iid 的***依赖项。

所以在上面的日志中,您可以看到有 2 个过时版本的 firebase-iid@16.2.0 示例。一个来自 --task/module dep -> firebase-messaging@17.1.0 另一个来自第三方库。我们无法控制第三方库,所以这里无事可做。

但是对于另一个依赖,我们必须用正确的版本显式声明它,这将强制使用这个:

实现 'com.google.firebase:firebase-messaging:20.0.0'

因此,您可能可以使用此命令了解问题的主要原因。

【讨论】:

以上是关于使用自己的身份验证服务器复制 firebase-auth 模块和 firebase-common-auth的主要内容,如果未能解决你的问题,请参考以下文章

如何使用没有密码的 SSH 身份验证连接到 Windows SFTP 服务器? [复制]

如何在客户端启动 GMAIL Api 身份验证? [复制]

SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应为:5.5.1 需要身份验证。 [复制]

在 C# 中复制具有身份验证的文件

在 C# 中复制具有身份验证的文件

如何使用 Firebase 身份验证服务并在我们自己的数据库中拥有用户?