【问题标题】:App Gradle, how I can fix error while use Firebase core?App Gradle,如何在使用 Firebase 核心时修复错误?
【发布时间】:2023-04-01 08:38:01
【问题描述】:

这是 build.gradle-app 文件:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "xxx.xxx.xxx"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.1.0"
        testInstrumentationRunner 
        "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
            'proguard-rules.pro'
        }
    }
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.firebase:firebase-iid:17.0.3'
    implementation 'com.google.firebase:firebase-analytics-impl:16.1.1'
    implementation 'com.google.firebase:firebase-analytics:16.0.4'

    compile 'com.android.support:support-annotations:27.1.1'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.github.chrisbanes:PhotoView:2.1.3'
    compile 'com.google.code.gson:gson:2.8.1'
    compile 'com.squareup.retrofit2:retrofit:2.4.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.android.support:animated-vector-drawable:26.1.0'
    compile 'com.android.support:gridlayout-v7:26.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.11.0'
    compile 'com.felipecsl:gifimageview:2.1.0'
    compile 'commons-io:commons-io:2.4'

    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation files('libs/YouTubeAndroidPlayerApi.jar')

}
apply plugin: 'com.google.gms.google-services'

这就是 build-gradle:

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'com.android.tools.build:gradle:3.3.0-alpha05'
    }
}

allprojects {
    repositories {
        maven {
            url 'https://maven.google.com'
            name 'Google'
        }
        maven {
            url "https://jitpack.io"
        }
        mavenLocal()
        mavenCentral()
        jcenter()
    }
}

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

我想创建一个 firebase 身份验证,并在设置页面上说要使用 firebase-core-16.0.1。我已按照出现错误时推荐的说明进行操作,添加了 firebase-analytics。

请帮我更正gradle上的错误代码,或者我能知道我可以使用的google服务或依赖版本的使用情况。

【问题讨论】:

  • 对所有 Firebase 依赖项使用相同的版本
  • 仍然无法正常工作,即使我只使用 firebase-core 16.0.4。出现了添加 Firebase 分析的建议,但我仍然出错
  • 删除implementation 'com.google.firebase:firebase-analytics-impl:16.1.1'implementation 'com.google.firebase:firebase-analytics:16.0.4'再试一次

标签: android firebase gradle android-gradle-plugin build.gradle


【解决方案1】:

要解决这个问题,请更改以下代码行:

classpath 'com.android.tools.build:gradle:3.3.0-alpha05'

classpath 'com.android.tools.build:gradle:3.2.1'

请同时删除以下代码行:

implementation 'com.google.firebase:firebase-iid:17.0.3'
implementation 'com.google.firebase:firebase-analytics-impl:16.1.1'

【讨论】:

  • 嗨史蒂文!你有没有试过我上面的解决方案,它有效吗?
  • 我试过了,但还是报错。 Android Studio 版本是否会影响 Gradle 中的库使用?
  • 还是报错,是什么?是的,应该兼容。
  • 在这一行中,实现 'com.google.firebase:firebase-core:16.0.4'。我会先尝试更新android studio
  • 好的,让我知道。
猜你喜欢
  • 1970-01-01
  • 2021-06-23
  • 1970-01-01
  • 1970-01-01
  • 2017-11-18
  • 1970-01-01
  • 2022-01-15
  • 2019-07-11
  • 1970-01-01
相关资源
最近更新 更多