【问题标题】:Error in implementing Firebase admin sdk in android studio在 android studio 中实现 Firebase admin sdk 时出错
【发布时间】:2020-03-15 01:00:10
【问题描述】:

当我实施 firebase 管理库时 它显示了我在下面的应用程序和项目级 gradle 文件之后提到的错误。

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

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    configurations {
        all*.exclude module: 'support-v4' // This removes all other versions of `support-v4` if gets duplicated from all the artifacts.
    }

    defaultConfig {
        applicationId "com.example.trolificnss"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.firebaseui:firebase-ui-auth:6.2.0"
    implementation 'com.google.firebase:firebase-auth:19.2.0'

    implementation 'com.google.firebase:firebase-admin:6.12.2'

    implementation 'com.google.firebase:firebase-analytics:17.2.3'
    implementation 'com.google.firebase:firebase-firestore:21.4.1'
    implementation 'com.firebaseui:firebase-ui-database:6.2.0'
    implementation 'com.firebaseui:firebase-ui-storage:6.2.0'
    implementation "com.google.firebase:firebase-firestore:21.4.1"
    implementation "com.firebaseui:firebase-ui-firestore:6.2.0"
    implementation 'com.firebaseui:firebase-ui-database:6.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.firebaseui:firebase-ui-firestore:6.2.0'
    implementation 'com.google.firebase:firebase-storage:19.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
    implementation 'net.schmizz:sshj:0.10.0'
}

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {


    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }

    }
    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
    }

}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

下面是错误信息,

在项目“app”中,解决了 Google Play 服务库依赖项 依赖于另一个确切版本(例如“[1.21.0]”,但不是 正在解决该版本。图书馆展示的行为将 不为人知。

【问题讨论】:

    标签: android firebase dependencies


    【解决方案1】:
    buildscript {
        ext.kotlin_version = '1.2.21'
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    ---------------------------------------------------------------------------
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    
    android {
        compileSdkVersion 26
    
        defaultConfig {
            applicationId "org.solamour.myserver"
            minSdkVersion 14
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
    
            javaCompileOptions {
                annotationProcessorOptions {
                    includeCompileClasspath false
                }
            }
            resConfigs "auto"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
        // Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app'.
        // Resolved versions for app (1.3.9) and test app (2.0.1) differ.
        configurations.all {
            resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1'    // Or "1.3.9".
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    
        implementation 'com.google.firebase:firebase-admin:4.1.6'
        implementation 'com.android.support:multidex:1.0.2'
    }
    
    
    
    
    take a look at the javadoc for FirebaseOptions Builder in the Android client library:
    
    com.google.firebase.FirebaseOptions.Builder
    
    Now look at the same class from the java Admin SDK (note the URL is different):
    
    com.google.firebase.FirebaseOptions.Builder 
    

    【讨论】:

      【解决方案2】:

      删除这个:

      implementation 'com.google.firebase:firebase-admin:6.12.2'
      

      您无法在 Android 应用中有效地使用 Firebase Admin SDK。它仅适用于在后端服务器和台式机上运行的代码。

      此外,您应始终确保您的 Android 客户端库依赖项为release notes 中显示的当前版本。您的 Firebase-UI 库版本还应与其他 Firebase 库匹配。

      【讨论】:

      • 那么,我应该用什么来调用其他用户的电子邮件?
      • 我不知道你在问什么。如果您需要使用 Admin SDK 做某事,您应该从客户端可以调用的后端执行此操作。
      • 我该怎么做,请你帮帮我?
      猜你喜欢
      • 1970-01-01
      • 2021-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-28
      • 2021-07-01
      • 2017-09-28
      • 1970-01-01
      相关资源
      最近更新 更多