使用 firebaseui:firebase-ui-firestore 构建发布 APK 时出现问题

Posted

技术标签:

【中文标题】使用 firebaseui:firebase-ui-firestore 构建发布 APK 时出现问题【英文标题】:Problem in build release APK with firebaseui:firebase-ui-firestore 【发布时间】:2021-07-07 17:29:44 【问题描述】:

我尝试为我的 APK 构建发布版本,但构建中存在问题,这在我的构建中显示

Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugandroidTestCompileClasspath'.
   > Could not find com.google.firebase:firebase-firestore:.
     Required by:
         project :app > com.firebaseui:firebase-ui-firestore:7.2.0

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

这是我的代码模块 build.gradle

plugins 
    id 'com.android.application'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.firebase-perf'
    id 'com.google.firebase.crashlytics'

android 
    compileSdkVersion 30
    buildToolsVersion "30.0.3"
    defaultConfig 
        applicationId "com.example"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 3
        versionName "2.7"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    
    buildTypes 
        release 
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        
    
    compileOptions 
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    
    sourceSets 
        main 
            assets 
                srcDirs 'src\\main\\assets'
            
        
    

dependencies 
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.navigation:navigation-fragment:2.3.5'
    implementation 'androidx.navigation:navigation-ui:2.3.5'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    implementation 'com.google.firebase:firebase-inappmessaging-display:20.0.0'
    implementation 'com.google.firebase:firebase-config:21.0.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
    implementation 'androidx.preference:preference:1.1.1'
    implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
    implementation 'com.airbnb.android:lottie:3.7.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
        // For control over item selection of both touch and mouse driven selection
        implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'

    // FireBase Start implementation
    implementation 'com.google.firebase:firebase-ads:20.2.0'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    implementation 'com.google.firebase:firebase-perf:20.0.1'
    implementation 'com.google.firebase:firebase-crashlytics:18.1.0'
    implementation 'com.google.firebase:firebase-analytics:19.0.0'
    implementation 'com.google.firebase:firebase-messaging:22.0.0'
    implementation 'com.firebaseui:firebase-ui-firestore:7.2.0'/*i think here is problem*/
    implementation 'com.firebaseui:firebase-ui-database:7.2.0'
    implementation 'com.google.firebase:firebase-bom:28.2.0'
    implementation 'com.google.firebase:firebase-database:20.0.0'
    implementation 'com.google.firebase:firebase-auth:21.0.1'
    // FireBase End implementation

    implementation 'com.github.tapadoo:alerter:7.1.0'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.20'
    implementation 'com.pranavpandey.android:dynamic-toasts:4.0.0'

这是项目 build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript 
    repositories 
        google()
        mavenCentral()
    
    dependencies 
        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath 'com.google.gms:google-services:4.3.8'
        classpath 'com.google.firebase:perf-plugin:1.4.0'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
    


allprojects 
    repositories 
        google()
        mavenCentral()
        maven  url "https://jitpack.io" 
    


task clean(type: Delete) 
    delete rootProject.buildDir

我尝试了很多方法来解决它,但问题仍然存在,如果您在我的 build.gradle 中有注释,请提醒我并感谢

【问题讨论】:

【参考方案1】:

在firebase documentation 中,他们还提到添加以下实现

implementation "com.google.firebase:firebase-firestore:$X.Y.Z"

implementation "androidx.legacy:legacy-support-v4:$X.Y.Z"
implementation "androidx.recyclerview:recyclerview:$X.Y.Z"

【讨论】:

非常感谢,罗汉

以上是关于使用 firebaseui:firebase-ui-firestore 构建发布 APK 时出现问题的主要内容,如果未能解决你的问题,请参考以下文章

设置库版本问题

测试使用

第一篇 用于测试使用

在使用加载数据流步骤的猪中,使用(使用 PigStorage)和不使用它有啥区别?

今目标使用教程 今目标任务使用篇

Qt静态编译时使用OpenSSL有三种方式(不使用,动态使用,静态使用,默认是动态使用)