【发布时间】:2018-07-19 09:23:38
【问题描述】:
我已添加
classpath 'com.google.gms:google-services:4.0.0'
到 buildscript/dependencies 中的项目级 gradle 文件。
我也加了
compile 'com.google.firebase:firebase-core:16.0.1'
到依赖项中的应用级 gradle 文件
我还添加了google-services.json 文件到应用文件夹。
我还添加了 apply plugin: 'com.google.gms.google-services' 到 app gradle 文件的顶部。 (教程说底部,但我也有织物在顶部,我认为没有问题,我也在底部测试过,结果相同)
当我尝试运行项目时,我收到了这个错误:
错误:任务 ':app:processBetaDebugManifest' 执行失败。
清单合并失败:属性 meta-data#android.support.VERSION@value value=(26.0.2) 来自 [com.android.support:recyclerview-v7:26.0.2] AndroidManifest.xml:25:13-35 也出现在 [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 价值=(26.1.0)。建议:添加 'tools:replace="android:value"' 到 AndroidManifest.xml:23:9-25:38 中的元素进行覆盖。
为什么会这样?我没有做任何改变,只是按照官方消息来源的描述添加了 Firebase。
我不想在我的清单中使用tools:replace,它在过去给我带来了很多错误。感觉就像是半解决方案或快速解决方案。
编辑:
项目级 gradle 文件:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级 gradle 文件:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
debuggable false
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// Specifies a flavor dimensions. Must have at least one.
flavorDimensions "myFlavorDimension"
productFlavors {
beta {
applicationId "hu.adamvarhegyi.myproject.beta"
versionCode 12
versionName '1.0.94 beta'
}
//Release
standard {
applicationId "hu.adamvarhegyi.myproject"
versionCode 12
versionName '1.0.94'
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = "my_project"
def SEP = "_"
def buildType = variant.variantData.variantConfiguration.buildType.name
def versionName = variant.versionName
def versionCode = "(v_" + variant.versionCode + ")"
def date = new Date();
def formattedDate = date.format('yyyy-MM-dd-HH-mm')
def newApkName = project + SEP + buildType + SEP + versionName + SEP + versionCode + SEP + formattedDate + ".apk"
outputFileName = new File(newApkName)
}
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
transitive = true;
}
compile project(':gameanalytics')
compile 'com.google.android.gms:play-services-basement:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile('com.android.support:appcompat-v7:26.0.2')
compile('com.android.support:recyclerview-v7:26.0.2')
compile 'com.android.support:gridlayout-v7:26.0.2'
compile('com.makeramen:roundedimageview:2.2.1')
compile('de.hdodenhof:circleimageview:2.1.0')
compile 'com.squareup.okio:okio:1.13.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.github.javiersantos:PiracyChecker:1.2.3'
compile 'com.google.firebase:firebase-core:16.0.1'
compile(name: 'my_project_engine', ext: 'aar')
}
【问题讨论】:
-
你在 gradle 模块的底部添加了这一行吗?应用插件:'com.google.gms.google-services'
-
你能分享项目和模块级别的 build.gradle
-
@WaleedAsim 是在上面但没关系,我也试过在底部,请看我的编辑,我已经提供了gradle文件
-
@adityakamble49 当然我已经添加了它们并进行了编辑
标签: android firebase android-manifest