1

在我的应用程序中,我试图使用gcm服务,但我甚至无法获得gradle编译。我不断收到我缺少'firebase核心'的消息,但我不知道如何安装它。找不到com.google.firebase:firebase-core:9.0.0?

这是我的顶级gradle这个文件:

buildscript { 
repositories { 
    jcenter() 

} 
dependencies { 
    classpath 'com.android.tools.build:gradle:2.1.2' 
    classpath "io.realm:realm-gradle-plugin:1.1.0" 
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 
    classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 

allprojects { 
repositories { 
    jcenter() 
    maven { 
     url "https://jitpack.io" 
    } 

    maven { 
     url "https://mint.splunk.com/gradle/" 
    } 
} 
} 

这里是我的模块级gradle这个文件:

apply plugin: 'com.android.application' 
apply plugin: 'realm-android' 
apply plugin: 'com.google.gms.google-services' 


android { 

compileSdkVersion 24 
buildToolsVersion "24.0.0" 
defaultConfig { 
    applicationId "roof.android" 
    minSdkVersion 17 
    targetSdkVersion 23 
    versionCode 11 
    versionName "0.0.4" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
packagingOptions { 
    exclude 'META-INF/NOTIC E.txt' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties' 
    exclude 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml' 
} 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 

// "The Android Support Library package contains several libraries that can be included in your application" -- https://developer.android.com/topic/libraries/support-library/features.html 
compile 'com.android.support:appcompat-v7:24.0.0' 

// "Native android recycler view library" -- https://developer.android.com/topic/libraries/support-library/features.html 
compile 'com.android.support:recyclerview-v7:24.0.0' 

// "A powerful image downloading and caching library for Android" -- http://square.github.io/picasso/ 
compile 'com.squareup.picasso:picasso:2.5.2' 

// "Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster" -- https://developer.android.com/training/volley/index.html 
compile 'com.android.volley:volley:1.0.0' 

// "JsonWebTokens in Auth0" -- https://auth0.com/docs/jwt 
compile 'com.auth0:java-jwt:2.1.0' 

// "Joda-Time provides a quality replacement for the Java date and time classes" -- http://www.joda.org/joda-time/ 
compile 'joda-time:joda-time:2.8.1' 

// "Android loading or progress dialog widget library, provide efficient way to implement iOS like loading dialog and progress wheel" -- https://github.com/Cloudist/ACProgressLite 
compile 'cc.cloudist.acplibrary:library:1.2.1' 

// "A RecyclerView that is powered by Realm and lots more" -- https://github.com/thorbenprimke/realm-recyclerview 
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.22' 

// "A beautiful ripple animation for your app" -- https://github.com/skyfishjy/android-ripple-background 
compile 'com.skyfishjy.ripplebackground:library:1.0.1' 

// "A logger with a small, extensible API which provides utility on top of Android's normal Log class." -- http://jakewharton.github.io/timber/ 
compile 'com.jakewharton.timber:timber:4.1.2' 

// "Field and method binding for Android views" -- http://jakewharton.github.io/butterknife/ 
compile 'com.jakewharton:butterknife:8.1.0' 
apt 'com.jakewharton:butterknife-compiler:8.1.0' 

// "An HTTP+HTTP/2 client for Android and Java applications." -- http://square.github.io/okhttp/ 
compile 'com.squareup.okhttp3:okhttp:3.3.1' 

// "Android client for Sentry" 
compile 'com.joshdholtz.sentry:sentry-android:1.4.1' 

compile 'com.google.android.gms:play-services-gcm:9.2.0' 

} 
+0

这可能无法解决您的即时问题,但您需要将'apply plugin:'com.google.gms.google-services''移动到您的模块gradle文件的**底部**。 [详细信息](https://developers.google.com/android/guides/google-services-plugin)。 –

+0

@泰迪威尔逊:请参阅下面我的回答 – FAT

回答

4

你想在你的应用程序中添加推送通知?

使用firebase而不是GCM。它是GCM的增强版本。

您需要以下关于Firebase推送通知的依赖关系。

compile 'com.google.firebase:firebase-messaging:9.0.1' 
compile 'com.google.android.gms:play-services-gcm:9.0.1' 

进一步信息请访问http://codingaffairs.blogspot.com/2016/06/firebase-cloud-messaging-push.html

+1

为什么你推荐Firebase? –

+0

,因为如果你读谷歌官方博客关于firebase的博文。他们还建议您将现有应用升级到Firebase :) –

+0

事实上,它具有更多功能,易于集成。 –

2

如果您要添加的火力点的核心,您可以在模块级gradle这个文件添加 compile 'com.google.firebase:firebase-core:9.0.0' 下dependencies标记。

如果仍然无法解决问题,也许您需要更新SDK以首先获得Google Play服务版本30和Google资源库版本26。细节请参阅here

13
  1. 在你的模块摇篮文件(通常是app/build.gradle),添加应用插件(apply plugin: 'com.google.gms.google-services')线在文件,以使摇篮插件的底部。

  2. 你也应该添加依赖的火力地堡com.google.firebase:firebase-corecom.google.firebase:firebase-messaging SDK的:

    apply plugin: 'com.android.application' 
    
    android { 
        // ... 
    } 
    
    dependencies { 
        // ... 
        compile 'com.google.firebase:firebase-core:10.2.1' 
        compile 'com.google.firebase:firebase-messaging:10.2.1' 
    } 
    
    // ADD THIS AT THE BOTTOM 
    apply plugin: 'com.google.gms.google-services' 
    

请确保您有最新版本的“谷歌Play服务”“谷歌版本库”在使用Firebase时安装了

请按照以下步骤安装:

  1. 打开Android工作室
  2. 转到菜单栏>工具>安卓> SDK管理器
  3. 点击选项卡> SDK工具
  4. 检查和安装'Google Play Services' and 'Google Repository'
  5. 点击Apply并等待下载广告

最后,同步构建再次你的项目。

相关问题