简体   繁体   English

如何修复Android Studio中的Appcompat错误

[英]How to fix appcompat error in android studio

I want to work with firebase real time database and when I implement firebase core and firebase database library appcompat get error. 我想与工作firebase实时数据库,当我实施firebase核心和火力数据库库appcompat得到错误。 My app module code is below? 我的应用模块代码如下?

 android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.mahdi.smsreviver"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies

    {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation 'com.google.firebase:firebase-database:16.1.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.google.firebase:firebase-core:16.0.7'
    }

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

Don't use appcompat, Use AndroidX the new support version library from Google. 请勿使用appcompat,请使用AndroidX(来自Google的新支持版本库)。 It has better compatibility features and other noticeable features. 它具有更好的兼容性和其他明显的功能。 Besides Appcompat is so Old. 除了Appcompat这么老。

from firebase release note you are using the latest version(firebase-core 16.0.7) which conflicts with appcompat version(27.1.1) firebase发行说明中,您使用的是最新版本(firebase-core 16.0.7),该版本与appcompat版本(27.1.1)冲突

so please update gradle 所以请更新gradle

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.mahdi.smsreviver"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7.28.0.0'
    implementation 'com.google.firebase:firebase-database:16.0.6'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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.7'
}

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM