我想在我的应用中添加带有Firebase的通知。 我在YouTube(https://www.youtube.com/watch?v=xx7hemn3FY4)上观看了一个视频 但是,当我在flutter项目中执行相同的操作时,我遇到了一个错误:com.google.android.gms:play-services-basement库正在由[[15.0.1,15.0.1]]的其他各种库请求,但解析为11.8.0。禁用插件,并使用./gradlew:app:dependencies检查您的依赖关系树。
正如您在评论中看到的,我尝试了几件事。
项目gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.1'
//classpath 'com.google.gms:google-services:4.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
/*
maven {
url "https://maven.google.com" // Google's Maven repository
}
*/
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.0"
}
}
}
}
App Gradle:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.weatherapp"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//Implementation 'com.google.android.gms:play-services-basement:15.0.1'
//Implementation 'com.google.firebase:firebase-core:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
但这些更改均无效。您还有其他想法吗?
答案 0 :(得分:5)
我遇到了类似的问题,在错误消息中指出了
其他[= [15.0.1,15.0.1]]的其他图书馆正在请求库com.google.android.gms:play-services-basement,但解析为11.8.0 。禁用插件,并使用./gradlew:app:dependencies检查您的依赖关系树。
已解决解析为11.8.0
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//Implementation 'com.google.android.gms:play-services-basement:15.0.1'
//Implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-core:11.8.0'. // <<--- Add this
}
我通过添加一行来解决我的问题
implementation 'com.google.firebase:firebase-core:11.8.0'. // <<--- Add this
如果这不能解决问题,请添加此行;
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
位于同一文件的末尾,如下所示;
...
dependencies {
....
}
....
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
让我知道它是否解决了我们的问题。
谢谢!
答案 1 :(得分:1)
发生此冲突是因为使用较旧的库解决方案是使用最新的库。 就我而言,我正在使用Firebase版本16.0.0,当前最新版本是16.0.4(07-02-2019)
const workbook: Excel.Workbook = new Excel.Workbook();
// code to generate the report - not an issue
workbook.xlsx.writeFile(path).then(...).catch(...)
而不是这个
implementation 'com.google.firebase:firebase-core:16.0.0'
答案 2 :(得分:-1)
检查firebase和其他Google服务是否相同。
表格
class PhotosController < ApplicationController
before_action :set_photo, only: [:show, :edit, :update, :destroy]
# GET /photos
# GET /photos.json
def index
@photos = Photo.all
end
# GET /photos/1
# GET /photos/1.json
def show
end
def show_first
@photos = Photo.find(1)
send_data @photos.image, :type => 'image/*',:disposition => 'inline'
end
def show_second
@photos = Photo.find(2)
send_data @photos.image, :type => 'image/*',:disposition => 'inline'
end
def show_third
@photos = Photo.find(3)
send_data @photos.image, :type => 'image/*',:disposition => 'inline'
end
def show_image
@photos = Photo.find(params[:id])
send_data @photos.image, :type => 'image/*',:disposition => 'inline'
end
# GET /photos/new
def new
@photo = Photo.new
end
# GET /photos/1/edit
def edit
end
# POST /photos
# POST /photos.json
def create
@photo = Photo.new(photo_params)
respond_to do |format|
if @photo.save
format.html { redirect_to @photo, notice: 'Photo was successfully created.' }
format.json { render :show, status: :created, location: @photo }
else
format.html { render :new }
format.json { render json: @photo.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /photos/1
# PATCH/PUT /photos/1.json
def update
respond_to do |format|
if @photo.update(photo_params)
format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }
format.json { render :show, status: :ok, location: @photo }
else
format.html { render :edit }
format.json { render json: @photo.errors, status: :unprocessable_entity }
end
end
end
# DELETE /photos/1
# DELETE /photos/1.json
def destroy
@photo.destroy
respond_to do |format|
format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_photo
@photo = Photo.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def photo_params
params.require(:photo).permit(:title, :medium, :description, :file)
end
end
到
implementation 'com.google.android.gms:play-services-maps:16.0.0'