gradle 文件中“com.android.support:appcompat-v7.27.1.1”的问题

新手上路,请多包涵

这是我的依赖文件,编译 ‘com.android.support:appcompat-v7.27.1.1’ 上有带下划线的红色文本

apply plugin: 'com.android.application'
 android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.abc.mcaproject"
    minSdkVersion 21
    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'])

compile 'com.android.support:appcompat-v7.27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-database:11.6.0'
implementation 'com.google.firebase:firebase-messaging:11.6.0'
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-storage:11.6.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'
}

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

因此,我在更改 styles.xml 中的主题时遇到问题

原文由 AL OK 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 354
2 个回答

当您将鼠标悬停在红线上时,它可能会向您显示我在下面附上的图像。 点击查看图片

它告诉您的是某些库中存在版本冲突,因此它建议我们添加这些库。对于我的情况,首先显示 CardView,然后显示 Design。所以我添加了它。下面是它的代码。

 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.0'
    implementation 'com.payumoney.sdkui:plug-n-play:1.2.0'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'

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

所以请添加那些它可能是 2 或更多。希望有所帮助。

原文由 Harsh Jain 发布,翻译遵循 CC BY-SA 4.0 许可协议

失败原因

您正在使用与 27.1.1 支持版本不兼容的 firebase 版本。

当前版本 > 16.0.0 并且你使用 11.6.0

解决方案

更新您的 firebase 依赖项版本。我建议也更新目标 sdk 版本。

以下是截至日期 1-10-2018 的更新 gradle,您可以查看 firebase 页面 以检查最新版本。

 apply plugin: 'com.android.application'
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.abc.mcaproject"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    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.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.firebase:firebase-database:16.0.2'
    implementation 'com.google.firebase:firebase-messaging:17.3.2'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-storage:16.0.2'
}

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

建议

Migrate to androidx 因为Android在28.0.0版本之后不会更新支持库。

原文由 Khemraj Sharma 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题