猿问

如何正确地将 MinSDKVersion 从 15 更改为 16 for firebase

我原来使用的是minSDKVersion 15,现在因为需要实现firebase,所以不得不改成16。使用以前版本的 firebase 不是一种选择。


只需将 build.gradle(Module:app) 中的 minSDKVersion 更改为 16,就会出现以下错误:


Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91

    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).

    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:8:5-40:19 to override.

我确实尝试了它提供的将 'tools:replace="android:appComponentFactory"' 添加到 AndroidManifest.xml 中的元素的建议,但这会产生更多错误。


我从这个改变了我的 build.gradle(Module:app) 文件:


apply plugin: 'com.android.application'


android {

    compileSdkVersion 28

    defaultConfig {

        applicationId "com.comapny.app"

        minSdkVersion 15

        targetSdkVersion 28

        versionCode 1

        versionName "1.0"

        testInstrumentationRunner "android.support.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.android.support:appcompat-v7:28.0.0'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.android.support:design:28.0.0'

    implementation 'com.android.support:support-v4:28.0.0'

    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.android.volley:volley:1.1.0'

}


德玛西亚99
浏览 134回答 1
1回答

POPMUISE

尝试将 firebase 依赖项从降级17.0.0为16.0.7这是我目前正在使用的版本并且可以正常工作。对 firebase 版本要非常小心。如果您设置了错误的版本,有些依赖项会使您的项目崩溃。这是我使用的一些稳定依赖项的列表:implementation 'com.google.firebase:firebase-core:16.0.7'implementation 'com.google.firebase:firebase-messaging:17.4.0'implementation 'com.google.firebase:firebase-auth:16.1.0'implementation 'com.google.firebase:firebase-firestore:18.1.0'implementation 'com.google.firebase:firebase-functions:16.3.0'implementation 'com.google.firebase:firebase-perf:16.2.3'implementation 'com.google.firebase:firebase-config:16.3.0'implementation 'com.google.firebase:firebase-database:16.1.0'
随时随地看视频慕课网APP

相关分类

Java
我要回答