In my project it failed to add "firebase" to android studio - android

I was adding firebase to my project as documented in the official website.
In the 4th step it says to add compile 'com.google.firebase:firebase-core:16.0.0'.
But trying to synch gradle I would get errors:
and by trying to download them (install repository abd synch project) I would get this error:
here is my gradle dependencies:
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
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.google.android.gms:play-services-gcm:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.android.gms:play-services-auth:15.0.1'
compile 'com.google.code.gson:gson:2.7'
compile('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
compile 'com.onesignal:OneSignal:3.6.5'
compile 'com.android.volley:volley:1.0.0'
testCompile 'junit:junit:4.12'
}
this answer did not work either:
this
update
My project-level gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
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
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
google()
}
}

Upgrade the following:
implementation 'com.google.firebase:firebase-auth:11.6.2'
into this:
implementation 'com.google.firebase:firebase-auth:16.0.2'
Add google service plugin version 4.0.1 and google() repo in top level gradle file:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
google() // Google's Maven repository
}
}

Use same versions of firebase services to avoid conflicts.
Refer https://firebase.google.com/docs/android/setup
To solve your problem.

Before you proceed, clean and rebuild your project.
Then at app/build.gradle,
add apply plugin: 'com.google.gms.google-services'
like the code snippet down below.
android {
// ...
}
dependencies {
// ...
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
And make sure all the library used are as here.
Hope it helps!

Add firebase-core to your dependencies block:
implementation 'com.google.firebase:firebase-core:16.0.1'
The Firebase SDK release notes for the June 12 release explain:
Your app gradle file now has to explicitly list
com.google.firebase:firebase-core as a dependency for Firebase
services to work as expected.
It's also safer to list google() first in repository lists:
repositories {
google()
jcenter()
...
}

Related

Failed to resolve: play-services-base

The error is not allowing gradle build to be successful.
My project level is below:
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'io.fabric.tools:gradle:1.24.4'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My app level gradle file dependencies
dependencies
{
implementation 'com.android.support:support-v4:28.0.0-alpha3'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.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.firebase:firebase-messaging:17.0.0'
implementation 'com.android.support:design:28.0.0-alpha3'
testCompile 'junit:junit:4.12'
implementation 'com.startapp:inapp-sdk:3.8.1'
implementation 'com.android.support:gridlayout-v7:28.0.0-alpha3'
implementation 'com.android.support:support-v4:28.0.0-alpha3'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
My Google Repository version is 58, Android Support Repository is 47.0.0, Android SDK Build Tools is 28.0.0
If you are using windows just delete .gradle folder in C:\users\"username"
I don't ever had android studio in Linux or Mac, but it must be: ~/.gradle
My issue solved this way.
Take care of order where you put google()
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}

Gradle build tool cannot find play-services-tasks.aar? Why?

Today suddenly, I got an error when I tried to run my app in Android studio.
It is:
Error: Could not find play-services-tasks.aar (com.google.android.gms:play-services-tasks:15.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar
I didn't change anything in the gradle file but it appeared suddenly. My previous build executed successfully some minutes ago.
Why it can't find play-services-tasks.aar which is the part of com.google.android.gms:play-services-tasks:15.0.1
Steps taken:
I checked whether I included all repositories in the gradle files and all are correct so far.
Why does this error occur all of a sudden?
I also copied this link https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar into the browser but it's working fine, that is, I got "File Download" dialog.
My Gradle Files
App level
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "mekanic24assistantapplication.heba.mekanic24.com.mekanic24assistantapplication"
minSdkVersion 14
targetSdkVersion 26
versionCode 13
versionName "2.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
// err Android Gradle Duplicate files copied in APK META-INF/license.txt
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:26+'
force 'com.android.support:support-annotations:26+'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:26.3.1'
compile 'com.android.support:appcompat-v7:26+'
compile 'com.android.support:design:26+'
compile 'com.android.support:recyclerview-v7:26+'
compile 'com.android.support:cardview-v7:26+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
androidTestCompile 'com.android.support:support-annotations:26+'
testCompile 'junit:junit:4.12'
// compile 'com.android.support:appcompat-v7:26.3.1'
compile 'com.github.markushi:circlebutton:1.1'
// compile 'com.android.support:design:26.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services-base:15.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.firebase:firebase-core:15.0.2'
compile 'com.google.firebase:firebase-messaging:15.0.2'
compile 'com.google.firebase:firebase-database:15.0.0'
compile 'com.wang.avi:library:2.1.3'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'android.lib.recaptcha:reCAPTCHA:2.0.0'
compile 'com.google.android.gms:play-services-safetynet:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-places:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
compile 'com.anjlab.android.iab.v3:library:1.0.38'
compile files('libs/mail.jar')
compile files('libs/additionnal.jar')
compile files('libs/activation.jar')
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.yarolegovich:lovely-dialog:1.1.0'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.github.stfalcon:smsverifycatcher:0.3.1'
compile 'ch.acra:acra:4.9.0'
//TODO: Apache 2.0 license https://github.com/ACRA/acra
compile 'com.google.android.gms:play-services-ads:15.0.1'
compile 'com.github.luongvo:GmailBackground:2.0.2'
}
apply plugin: 'com.google.gms.google-services'
Project Level
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
maven {
url "https://dl.bintray.com/android/android-tools"
}
maven { url "https://jitpack.io" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
maven {
url "https://dl.bintray.com/android/android-tools"
}
maven { url "https://jitpack.io" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After doing the following changes the error disappeared:
Removed maven { url 'https://maven.google.com' } from repositories in app build.gradle.
Added maven { url 'https://maven.google.com' } as first entry in allprojects/repositories in top level build.gradle
Changed all play-services and firebase dependencies to the latest versions
Changed version of google-services plugin to classpath 'com.google.gms:google-services:4.0.1'
The fix is to put google url above jcenter() in your repository list in gradle.
Here's the issue: https://issuetracker.google.com/issues/80362794
in my case:
allprojects {
repositories {
google()
jcenter()
}
}
solves my problems
in my old configuration was only "jcenter()"
first line jcenter(), second line google() doesn't work
For my case I removed mavenCentral() from app gradle repositores and moved maven { url 'https://maven.google.com' } to the first positionin in project gradle as Ivan Rigamonti suggested above. No Firebase dependecies update needed.
(this should be a comment, but I don't have enough reputation)
I am getting the same issue today. It was working fine until now. Maybe it's a temporary Google servers issue.
The solution that works for me is using an older version of google-play-services:
implementation 'com.google.android.gms:play-services-maps:11.4.2'
Change
compile 'com.google.android.gms:play-services-safetynet:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-places:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
to
compile 'com.google.android.gms:play-services-safetynet:16.0.0'
compile 'com.google.android.gms:play-services-maps:16.0.0'
compile 'com.google.android.gms:play-services-places:16.0.0'
compile 'com.google.android.gms:play-services-location:16.0.0'
Is my case, it works!
Could it be that google changed the naming conventions of the packages on the server side?
I'm experiencing the same sort of issue with a different play services package just now.
Namely play-services-basement.aar...
I'm thinking that
Could not find play-services-tasks.aar
Means it's looking for the file named as play-services-tasks.aar
While on the server this file is called:
play-services-tasks-15.0.1.aar
I'm thinking this is either a gradle issue where files aren't named correctly or a server side issue where files aren't named correctly.
Please correct me if I'm mistaken here.
EDIT: this issue should be reported to jcenter.bintray.com since they are the ones being at fault here at their server side. Switching to the Maven repository mentioned by Ivan Rigamonti could be a solution but I'm uncertain how ionic apps deal with switching repositories.
EDIT2: Switching to the maven repository does indeed work for ionic. All I had to do for ionic was to alter build.gradle by putting jcenter() underneath maven() inside of the buildscript repositories and allprojects repositories.
if you Guys Getting Error Like build.gradle error , Failed to resolve: common like this build.gradle error , Failed to resolve: common
then put below line in allprojects scope in repositories scope in Project build.gradle
line :
maven { url 'https://maven.google.com' }
jcenter()
google()
example
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
google()
}

build.gradle error , Failed to resolve: common [duplicate]

Today suddenly, I got an error when I tried to run my app in Android studio.
It is:
Error: Could not find play-services-tasks.aar (com.google.android.gms:play-services-tasks:15.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar
I didn't change anything in the gradle file but it appeared suddenly. My previous build executed successfully some minutes ago.
Why it can't find play-services-tasks.aar which is the part of com.google.android.gms:play-services-tasks:15.0.1
Steps taken:
I checked whether I included all repositories in the gradle files and all are correct so far.
Why does this error occur all of a sudden?
I also copied this link https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar into the browser but it's working fine, that is, I got "File Download" dialog.
My Gradle Files
App level
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "mekanic24assistantapplication.heba.mekanic24.com.mekanic24assistantapplication"
minSdkVersion 14
targetSdkVersion 26
versionCode 13
versionName "2.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
// err Android Gradle Duplicate files copied in APK META-INF/license.txt
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:26+'
force 'com.android.support:support-annotations:26+'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:26.3.1'
compile 'com.android.support:appcompat-v7:26+'
compile 'com.android.support:design:26+'
compile 'com.android.support:recyclerview-v7:26+'
compile 'com.android.support:cardview-v7:26+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
androidTestCompile 'com.android.support:support-annotations:26+'
testCompile 'junit:junit:4.12'
// compile 'com.android.support:appcompat-v7:26.3.1'
compile 'com.github.markushi:circlebutton:1.1'
// compile 'com.android.support:design:26.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services-base:15.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.firebase:firebase-core:15.0.2'
compile 'com.google.firebase:firebase-messaging:15.0.2'
compile 'com.google.firebase:firebase-database:15.0.0'
compile 'com.wang.avi:library:2.1.3'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'android.lib.recaptcha:reCAPTCHA:2.0.0'
compile 'com.google.android.gms:play-services-safetynet:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-places:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
compile 'com.anjlab.android.iab.v3:library:1.0.38'
compile files('libs/mail.jar')
compile files('libs/additionnal.jar')
compile files('libs/activation.jar')
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.yarolegovich:lovely-dialog:1.1.0'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.github.stfalcon:smsverifycatcher:0.3.1'
compile 'ch.acra:acra:4.9.0'
//TODO: Apache 2.0 license https://github.com/ACRA/acra
compile 'com.google.android.gms:play-services-ads:15.0.1'
compile 'com.github.luongvo:GmailBackground:2.0.2'
}
apply plugin: 'com.google.gms.google-services'
Project Level
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
maven {
url "https://dl.bintray.com/android/android-tools"
}
maven { url "https://jitpack.io" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
maven {
url "https://dl.bintray.com/android/android-tools"
}
maven { url "https://jitpack.io" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After doing the following changes the error disappeared:
Removed maven { url 'https://maven.google.com' } from repositories in app build.gradle.
Added maven { url 'https://maven.google.com' } as first entry in allprojects/repositories in top level build.gradle
Changed all play-services and firebase dependencies to the latest versions
Changed version of google-services plugin to classpath 'com.google.gms:google-services:4.0.1'
The fix is to put google url above jcenter() in your repository list in gradle.
Here's the issue: https://issuetracker.google.com/issues/80362794
in my case:
allprojects {
repositories {
google()
jcenter()
}
}
solves my problems
in my old configuration was only "jcenter()"
first line jcenter(), second line google() doesn't work
For my case I removed mavenCentral() from app gradle repositores and moved maven { url 'https://maven.google.com' } to the first positionin in project gradle as Ivan Rigamonti suggested above. No Firebase dependecies update needed.
(this should be a comment, but I don't have enough reputation)
I am getting the same issue today. It was working fine until now. Maybe it's a temporary Google servers issue.
The solution that works for me is using an older version of google-play-services:
implementation 'com.google.android.gms:play-services-maps:11.4.2'
Change
compile 'com.google.android.gms:play-services-safetynet:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-places:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
to
compile 'com.google.android.gms:play-services-safetynet:16.0.0'
compile 'com.google.android.gms:play-services-maps:16.0.0'
compile 'com.google.android.gms:play-services-places:16.0.0'
compile 'com.google.android.gms:play-services-location:16.0.0'
Is my case, it works!
Could it be that google changed the naming conventions of the packages on the server side?
I'm experiencing the same sort of issue with a different play services package just now.
Namely play-services-basement.aar...
I'm thinking that
Could not find play-services-tasks.aar
Means it's looking for the file named as play-services-tasks.aar
While on the server this file is called:
play-services-tasks-15.0.1.aar
I'm thinking this is either a gradle issue where files aren't named correctly or a server side issue where files aren't named correctly.
Please correct me if I'm mistaken here.
EDIT: this issue should be reported to jcenter.bintray.com since they are the ones being at fault here at their server side. Switching to the Maven repository mentioned by Ivan Rigamonti could be a solution but I'm uncertain how ionic apps deal with switching repositories.
EDIT2: Switching to the maven repository does indeed work for ionic. All I had to do for ionic was to alter build.gradle by putting jcenter() underneath maven() inside of the buildscript repositories and allprojects repositories.
if you Guys Getting Error Like build.gradle error , Failed to resolve: common like this build.gradle error , Failed to resolve: common
then put below line in allprojects scope in repositories scope in Project build.gradle
line :
maven { url 'https://maven.google.com' }
jcenter()
google()
example
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
google()
}

Gradle DSL method not found: 'implementation()'

I had this error
Error:(45, 0) Gradle DSL method not found: 'implementation()'
Possible causes:<ul><li>The project 'LaTaxi2' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.3 and sync project</li><li>The project 'LaTaxi2' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
build.gradle content
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
url 'https://maven.google.com'
}
// google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
/* CHANGE to classpath 'com.android.tools.build:gradle:2.3.3' for STABLE BUILD TOOL VERSION*/
// classpath 'com.android.tools.build:gradle:3.0.0-alpha7'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// 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+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
// google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build .gradle module app
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven {
url 'https://maven.google.com'
}
// google()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "in.techware.lataxi"
minSdkVersion 17
targetSdkVersion 25
versionCode 5
versionName "1.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
/* Remove This to remove Crashlytics and Fabric */
compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}
/* compile('com.digits.sdk.android:digits:2.0.6#aar') {
transitive = true;
}*/
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:design:25.4.0'
implementation 'com.android.support:recyclerview-v7:25.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.android.support:cardview-v7:25.4.0'
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.google.android.gms:play-services-maps:11.0.2'
implementation 'com.google.android.gms:play-services-location:11.0.2'
implementation 'com.google.android.gms:play-services-places:11.0.2'
implementation 'com.google.firebase:firebase-auth:11.0.2'
implementation 'com.google.firebase:firebase-messaging:11.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
implementation 'com.google.code.gson:gson:2.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I had such a simple reason for this not working that I must post my answer to prevent anybody else going through this.
Don't put repositories and dependencies in the file called build.gradle (Project: YourProjectName)! There is a comment in that file that says:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Good job to whoever put that note in there. Instead, place your repositories and dependencies in the similarly named module file build.gradle (Module: app).
There should already be a dependencies function. You may need to add repositories function. In my case, it was:
repositories {
maven { url "https://jitpack.io" }
}
This should let you sync and recognize implementation.
To use the DSL implementation() you have to use:
The updated gradle plugin for Android 3.0.0
The gradle version 3.4 or later
Then in your build.gradle you have to use:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
}
}
In your gradle-wrapper.properties
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
More detailed info here.
or if you don't want to update to the latest Gradle, go back to using DSL method compile() instead of implementation()
As a beginner, I discovered that there's 2 build.gradle files
It's worth checking that you didn't add the line in the wrong file.
I added mine in the project file whereas I should have added it in the module one.
You using Turkish workspace,
below change solves the problem
testImplementation -> testİmplementation,
androidTestImplementation -> androidTestİmplementation
androidTestImplementation -> androidTestİmplementation
implementation() has replaced compile() configuration, which will be DEPRECATED by the end of 2018.
In order to fix your errors and use it, you must update to Android Gradle Plugin 3.0.0 (or higher). As a result of this update, you also need to update Gradle to Gradle 4.1 (or higher). You also need to use Build Tools 26.0.2 (or higher), meaning to update your buildToolsVersion in your build.gradle, or just completely remove it from there (as, since 3.0.0, the minimum required version is used by default). You also need to update to Android Studio 3 (or higher) in order to use those advanced versions.
You can read about the changelog of android gradle plugin 3.0.0, the improved compile times, and more, here:
https://developer.android.com/studio/releases/gradle-plugin#3-0-0
So how to update Android Gradle Plugin and Gradle?
OPTION 1: Manually
In your build.gradle find your gradle classpath and update version to gradle 3.0. Also, google() maven's repository should be added:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
In gradle-wrapper.properties find your distributionUrl and update to:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
OPTION 2: Through project properties
(But notice the manual configuration WILL override it)
Go to File→Project Structure→Project
One last thing, you can also choose whether to replace compile() by implementation() or by api(). By default I would suggest just to use implementation(). You can read more about the differences here:
https://developer.android.com/studio/build/dependencies
In my case it was just a typo. It was an extra sign "/" after one of rows
I ran into similar errors. when I tried to include the recyclerview dependencies from may build.gradle(Module: app) with a code like so.
//other build.gradle(Module: App) code above
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.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:recyclerview-v7:25.3.1'
}
So the simple way I fixed this is by changing the code to this, where I changed the implement to compile while retaining every other code and their version numbers.
//other build.gradle(Module: App) code above
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.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:25.3.1'
}
I hope this helps some one having similar issues.
PS: The actual error was caused by implementation 'com.android.support:recyclerview-v7:25.3.1' and changing the code to compile 'com.android.support:recyclerview-v7:25.3.1' got it fixed.
in my case i add these line and issue resolved
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

Android Execution failed for task app.compileDebugKotlin when firebase is used

Getting this error
Error:Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
As soon as I add this line of code to the app
firebaseAuth = FirebaseAuth.getInstance()
Dependency is added to gradle app module
compile 'com.google.firebase:firebase-auth:10.0.1'
Any idea what's causing this error?
EDIT
: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.google.firebase.auth.FirebaseAuth, unresolved supertypes: com.google.android.gms.internal.zzbql
but I do have it
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:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'io.reactivex:rxkotlin:0.21.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.dagger:dagger:2.4'
testCompile 'junit:junit:4.12'
kapt 'com.google.dagger:dagger-compiler:2.4'
provided 'org.glassfish:javax.annotation:10.0-b28'
}
**Project gradle**
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.2-5'
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
**app gradle**
dependencies {
implementation 'com.google.firebase:firebase-auth:11.0.2'
implementation 'com.google.firebase:firebase-database:11.0.2'
implementation 'com.google.firebase:firebase-ads:11.0.2'
implementation 'com.google.android.gms:play-services-location:11.0.2'
}
**Please add this below dependencies and make sure firebase and play-services versions should be same.**
apply plugin: 'com.google.gms.google-services'

Categories

Resources