【问题标题】:"com.android.support:appcompat-v7:28.0.0" Error“com.android.support:appcompat-v7:28.0.0”错误
【发布时间】:2019-04-04 06:34:21
【问题描述】:

每当我添加 firebase 数据库依赖项时,它都会显示 appcompat 错误。像这样

"所有 com.android.support 库必须使用完全相同的版本 规范(混合版本可能导致运行时崩溃)。成立 版本 28.0.0、26.1.0。例子包括 com.android.support:animated-vector-drawable:28.0.0 和 com.android.support:support-media-compat:26.1.0"

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

【问题讨论】:

  • 什么是 gradle 目标版本代码和名称?
  • 发布您的应用程序级别和项目级别 gradle,因为我尝试了您的依赖项及其工作正常
  • 也是com.android.support:support-media-compat:26.1.0也是这个版本28.0.0
  • compileSdkVersion 28 defaultConfig { applicationId "com.example.uemultancampus" minSdkVersion 23 targetSdkVersion 28
  • 感谢您的回复,但我在这里给出了错误。

标签: android firebase-realtime-database


【解决方案1】:

"所有 com.android.support 库必须使用完全相同的版本 规范(混合版本可能导致运行时崩溃)。成立 版本 28.0.0、26.1.0。例子包括 com.android.support:animated-vector-drawable:28.0.0 和 com.android.support:support-media-compat:26.1.0"

解决方案:com.android.support:support-v4:28.0.0 依赖添加到您的gradle 文件中。

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.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'

    // Add this line
    implementation 'com.android.support:support-v4:28.0.0'
}

【讨论】:

    【解决方案2】:

    添加依赖 implementation 'com.android.support:support-v4:28.0.0'implementation 'com.android.support:appcompat-v7:28.0.0'

    也是支持库 28.0.0 的稳定版本,是 android.support 打包下的最后一个功能版本,鼓励开发者迁移到 AndroidX

      android {
      compileSdkVersion 28
      buildToolsVersion "28.0.3"
    
    
     defaultConfig {
     applicationId "com.your_project_name"
     minSdkVersion 23
     targetSdkVersion 28
     versionCode 1
     multiDexEnabled true
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    
     dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     implementation 'com.android.support:appcompat-v7:28.0.0'
     implementation 'com.android.support:support-v4:28.0.0'
     implementation 'com.android.support:design:28.0.0'
     implementation 'com.android.support:cardview-v7:28.0.0'
     implementation 'com.android.support:recyclerview-v7:28.0.0'
     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.crashlytics.sdk.android:crashlytics:2.9.5' 
     }
    

    【讨论】:

      【解决方案3】:
      implementation 'com.android.support:support-media-compat:28.0.0'
      
      implementation 'com.android.support:support-v4:28.0.0'
      

      添加依赖并改变

      implementation 'com.google.firebase:firebase-database:16.1.0'
      

      implementation 'com.google.firebase:firebase-database:9.0.2'
      

      这对我有用

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-04
        • 2019-04-05
        • 1970-01-01
        • 2020-05-12
        • 1970-01-01
        • 2021-02-26
        • 1970-01-01
        相关资源
        最近更新 更多