Reputation: 1101
i have android project and i want to add push notifications to that app using google firebase first i downloaded the xml file and past it on app root then i added this lines as they said on this link
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:4.0.0'
}
}
dependencies {
// Add this line
compile 'com.google.firebase:firebase-core:16.0.0'
}
...
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
and i click sync now always gat this error
failed to resolve: com.google.firebase:firebase-core:16.0.0
thank for help this is the full gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "28.0.0"
defaultConfig {
applicationId "com.softya.demo"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:16.0.0'
}
apply plugin: 'com.google.gms.google-services'
and this is the gradle file code
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Upvotes: 1
Views: 5675
Reputation: 4024
I solved this with this script in the build.gradle [Proyect]
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
maven {
url 'https://dl.bintray.com/android/android-tools'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
}
Upvotes: 1
Reputation: 1565
You have to add the google() Google's Maven repository for all projects
allprojects {
repositories {
jcenter()
google()
}
}
Upvotes: 2
Reputation: 4085
I notice you need to updates a lot of your scripts.
For example, let's start with your top-level build.gradle
. You should no longer use android gradle plugin 2.+, instead you should use version 3.1.x
And to do that, you should put google()
in your repositories.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
//Add this line
google()
}
dependencies {
//Please update it to 3.1.x
classpath 'com.android.tools.build:gradle:3.1.2'
//Update to the latest version as well
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Some tips:
Try to update your app-level build.gradle
, from compile
to implementation
since they will be deprecated soon.
Upvotes: 2