Lou*_* L. 67 android gradle cloud-storage firebase android-gradle-plugin
我正在尝试将firebase云存储添加到我的应用程序中.下面是app build.gradle.但它说:无法解决:com.google.firebase:firebase-core:16.0.1.为什么?依赖项中根本没有firebase-core.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.louise.udacity.mydict"
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.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.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'
implementation 'com.google.cloud:google-cloud-storage:1.31.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
Pet*_*dad 109
来自文档: -
您的应用程序gradle文件现在必须明确列出
com.google.firebase:firebase-core作为Firebase服务的依赖项才能按预期工作.
加:
implementation 'com.google.firebase:firebase-core:16.0.1'
Run Code Online (Sandbox Code Playgroud)
在顶级gradle文件中使用最新版本的google play服务:
classpath 'com.google.gms:google-services:4.0.2'
Run Code Online (Sandbox Code Playgroud)
https://firebase.google.com/support/release-notes/android
https://bintray.com/android/android-tools/com.google.gms.google-services
注意:
您需要google()在顶级gradle文件中添加repo,如firebase文档中所指定的那样,它应该在之前jcenter():
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
https://firebase.google.com/docs/android/setup
自2018年5月23日更新以来,当您使用firebase依赖项时,您也必须包含firebase-core依赖项.
如果添加它,您仍然有错误,尝试更新您gradle-wrapper.properties的4.5版本中的gradle插件:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
Run Code Online (Sandbox Code Playgroud)
并重新同步项目.
我得到了同样的问题,我通过替换解决了它:
implementation 'com.google.firebase:firebase-core:16.0.1'
Run Code Online (Sandbox Code Playgroud)
至
implementation 'com.google.firebase:firebase-core:15.0.2'
Run Code Online (Sandbox Code Playgroud)
一切都解决了,运作良好.
小智 5
将maven {url" https://maven.google.com "}添加到根级build.gradle文件中
repositories {
maven { url "https://maven.google.com" }
flatDir {
dirs 'libs'
}
}
Run Code Online (Sandbox Code Playgroud)
正如@Peter Haddad所述,
为了解决此问题,我遵循了Google Firebase集成准则,并对我的app / build.gradle和project / build.gradle进行了以下更改
如果您有任何疑问,请点击以下提到的链接
https://firebase.google.com/docs/android/setup
app / build.gradle中的更改
implementation 'com.google.android.gms:play-services-base:15.0.2'
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.4.0"Run Code Online (Sandbox Code Playgroud)
Project / build.gradle中的更改
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.2.0'// // google-services plugin it should be latest if you are using firebase version 16.0 +
}
allprojects {
repositories {
google()// add it to top instead of bottom or somewhere in middle
mavenLocal()
mavenCentral()
maven {
url 'https://maven.google.com'
}
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
97342 次 |
| 最近记录: |