I've been trying to setup Firebase in my Android project.
Problem is, I've been getting this error:
Could not parse the Android application Module's Gradle Config
And I really can't solve it.
I've seen quite a lot of people getting this error, but it seems that they could solve it by upgrading their build tool version, or by updating google-services. I've done all that and haven't been able to make it work so far.
Here are my Gradle scripts:
apply plugin: 'com.android.application'
android {
signingConfigs {
AndroidAppPro {
}
}
compileSdkVersion 25
buildToolsVersion '26.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.critizr.pro"
minSdkVersion 14
targetSdkVersion 25
versionCode 9
versionName "1.5.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
preprod {
applicationId "com.cr.pro"
buildConfigField 'boolean', 'IS_PROD', 'false'
buildConfigField 'String', 'HOST', '"https://myurl.com/"'
}
prod {
applicationId "com.cr.pro"
buildConfigField 'boolean', 'IS_PROD', 'true'
buildConfigField 'String', 'HOST', '"https://myurl/"'
}
}
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 project(':lib-viewflow')
// new libs
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.google.android.gms:play-services-gcm:11.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.2'
//compile 'com.google.android.gms:play-services-analytics:11.0.1'
compile 'org.apache.httpcomponents:httpclient:4.1'
compile 'org.apache.httpcomponents:httpmime:4.1'
compile 'com.joshdholtz.sentry:sentry-android:1.5.0'
compile 'com.borax12.materialdaterangepicker:library:1.6'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.cloudinary:cloudinary-core:1.2.2'
compile 'com.cloudinary:cloudinary-android:1.2.2'
compile 'com.loopj.android:android-async-http:1.4.5'
}
apply plugin: 'com.google.gms.google-services'
And the second one:
buildscript {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
For me by removing the warning of jCenter worked
jCenter() remove it..
To solve this on Android Studio v3.1 (not sure about previous versions), just edit your app's build.gradle like this:
Look for:
apply plugin: 'com.google.gms.google-services' and remove it then sync. Now you'll be able to use the Firebase Assistant with no issues.
Verify the build tab, and make sure you've got no warnings in there.
Firebase Assistant seems to be very sensitive to any Gradle info, warning, or error.
For me it was a simple "info" from gradle, that databinding.enabled is not required anymore:
DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.
Once removed, Firebase Assistant worked fine.
The Navigation Component's safeargs plugin can also cause this. To fix it, I temporarily removed id 'androidx.navigation.safeargs.kotlin' from app-level build.gradle file and then added it back in afterwards.
Commenting out apply plugin: io.fabric worked for me. So check your dependencies in your gradle file.
I think some of your dependencies are behind it . Just go to your build.gradle (module app) and comment out most of them or all of them (to find out which one) , sync again ignore all error for now and try connecting to firebase again if it's successful then you can go back to your build.gradle and uncomment them to fix errors.
Hope this helps
I had a problem for viewBinding. Did as in the instructions from Google and it all worked.
android {
...
buildFeatures {
viewBinding true
}
}
My problem was the jcenter Repository, because it is deprecated since March 31st 2021, see: https://developer.android.com/studio/build/jcenter-migration
I replaced jcenter() with mavenCentral(). Now it works.
change the gradle build tool version to 3.0.1
This error occurs due to depreciation of the Compile keyword in built.gradle(app level)
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018.
Its Solution is to
Just replace the compile keyword with implementation or api in built.gradle(app level)
&
Rebuilt your project
Restart your Android Studio if not Solved after Rebuilt.
Conclusion
The real culprit is the warnings of your build.gradle. Firebase assistant is very sensitive, it checks for any warning (even deprecated one) in your build.gradle & then starts working. If it finds any, then you will get this error.
Solution
Just remove or resolve every warning of the build.gradle file. also, remove plugins that already exist of the same thing you are adding.
Remove all previous Firebase dependencies in your project and try again. Plugins and libraries.
I had this issue before because I had already setup Firebase manually.
Hope it helps.
If you are not use databinding remove from your app level gradle
dataBinding {
enabled = true
}
Remove these lines from your app level gradle
In my case this was caused because I used data binding in my project. Here is how I fixed the issue:
In your build.gradle(App level) set the dataBinding as follow:
Put this code in your build.gradle(Project level) under the buildTypes:
//Here is the code...
buildFeatures {
dataBinding = true
}
Follow the solution step by step.
1. In Gradle Script/build.gradle(Project:your project name):
Add dependencies
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath 'com.google.gms:google-services:4.3.8'
}
}
jcenter remove or do comment out:
allprojects {
repositories {
google()
mavenCentral()
// jcenter() // Warning: this repository is going to shut down soon
}
}
2. In Gradle Script/gradle.properties:
android.useAndroidX=true
3. In Gradle Script/build.gradle(:app):
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
before build types add buildFeatures:
buildFeatures {
dataBinding = true
}
at the last:
dependencies {
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-database:20.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
4. Add google servises json file
location:
D:\AndroidStudioProjects\Whatsup_project\app
See the youtube video on how to add a JSON file.
In my case most of the dependencies were included with compile rather than implementation. So converting compile to implementation in my build.gradle(Module : app) worked perfectly
in case of flutter project after commenting this line worked for me
//apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
After very long trying many things.
this solved me : changing google services version to 4.2.0 in build gradle
classpath 'com.google.gms:google-services:4.2.0'
now my build gradle looks like this:
buildscript {
repositories {
google()
jcenter()
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
}
}
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
}
allprojects {
repositories {
google()
jcenter()
}
}
}
When I was facing this problem I have simply removed 20.0.1 from,
implementation 'com.google.firebase:firebase-auth:20.0.1'
(NOTE: I have implemented firebase-boM first so it has occurred in my case.)
Then synced and tried reconnecting then it was successful.
I think it occurs for many reasons.
If you are using firebase boM. then don't specify any other firebase dependencies versions. after successful sync, it should be solved.
In your case, I can not declear why it is happening.
What solved my issue was:
deleting
databinding{enabled = true}
and inserting
buildFeatures{dataBinding = true}
Basically, you need to remove all the gradle warning before doing this. In my case, I used buildFeatures { viewBinding true}
instead of
buildFeatures { dataBinding true }
I also face this problem and I found the best way to solve this problem is: connect your Application manually to the firebase database.
To enable google firebase services in your app you need to add google services plugin to your gradle file(build.gradle). so in the gradle file
under dependencies add :
classpath 'com.google.gms:google-services:4.3.0' // Google Services plugin
under repositories check that you have Google's Maven repository as
google() //Google's Maven repository
For detailed breakdown on how to set up firebase check here for the official documentation.
Remove following from Gradle
testImplementation 'junit:junit:'
This worked for me and also connected to Firebase without any issue, you just need to rebuild project and then click on connect to firebase. It's done.
I just had a similar issue. I had to delete useProguard from the buildTypes in your app gradle.
After that I did not get the warning any more
In my case, I had to change minSdkVersion in build.gradle(Module: app) file to 25 and it worked.
in my case i update the minSdkVersion in build.gradle to the last one 28.0.3 and after i sync it work fine
This worked for me!
Go to Gradle.properties in your android
Disable android.enableR8=true by adding a # in front:
#android.enableR8=true
Alternatively, you can swap out the R8 for D8, The build system changed to using D8 instead of R8.
android.enableD8=true
Change the versions to below.
dependencies {
classpath "com.android.tools.build:gradle:3.6.1"
classpath 'com.google.gms:google-services:4.3.3'
}
Try changing the Android Gradle Plugin Version to 4.1.3 and the Gradle Version to 6.5 in Project Structure. It helped me and it might help you too. Android Firebase: Could not parse
Related
I'm using Android Studio 3.2 Beta5 to migrate my project to AndroidX. When I rebuild my app I got these errors:
ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}'
ERROR: [TAG] Failed to resolve variable '${junit.version}'
Full clean & rebuild did not work! Anyone know how to fix this?
gradle.properties
android.enableJetifier=true
android.useAndroidX=true
build.gradle
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-beta05'
classpath 'com.google.gms:google-services:4.0.1'
classpath "io.realm:realm-gradle-plugin:5.3.1"
classpath 'io.fabric.tools:gradle:1.25.4'
classpath 'com.google.firebase:firebase-plugins:1.1.5'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 28
buildToolsVersion "28.0.0"
defaultConfig {
applicationId "com.iceteaviet.fastfoodfinder"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc01'
implementation 'androidx.cardview:cardview:1.0.0-rc01'
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'io.realm:realm-android-library:5.3.1'
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.0.2'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
implementation 'com.google.firebase:firebase-perf:16.0.0'
implementation 'com.jakewharton.timber:timber:4.7.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
}
apply plugin: 'com.google.gms.google-services'
I fix this with two steps
1) File -> Invalidate Caches / restart...
2) Build -> Clean project
I got the same error after updating my build.gradle file with AndroidX Test dependencies. Turns out I forgot to remove the old junit dependency. So for me, the fix was simply to remove the following dependency:
dependencies {
...
testImplementation 'junit:junit:4.12'
}
Adding Java 8 support to build.gradle file fixed issue for me
android {
...
//Add the following configuration in order to target Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
It seems to be Glide the problem.
I had the same error and I just updated the Glide's dependencies to 4.8 and there is no build errors.
Kotlin :
// Glide
def glide_version = "4.8.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
Java :
// Glide
def glide_version = "4.8.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"
Be sure to have enabled in your gradle.properties :
android.useAndroidX=true
android.enableJetifier=true
Source : https://github.com/bumptech/glide/issues/3124
Hope this will help you!
Fixed it by going to the main directory and typing flutter clean
Removing the testInstrumentationRunner worked for me:
defaultConfig {
...
...
// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
If you're using Kotlin, the issue will popup if don't use the kapt version for any annotation processor you use in the project.
As #Vince mentioned the case with Glide, this could happen with Dagger2, Butterknife, etc.
If you're using both Java and Kotlin you'll need to keep both dependencies, as follows (were $glideVersion is a predefined version of Glide):
implementation "com.github.bumptech.glide:glide:$glideVersion"
kapt "com.github.bumptech.glide:compiler:$glideVersion"
If you're on a Kotlin only project, the kapt dependency should work alone.
EDIT
Another thing you should have in mind is if you're already using Androidx. Androidx is a great refactor but when migrating it can cause some of your dependencies to collapse. Mainstream libraries are already updated to Androidx, however, some of them are not and even won't.
If the issue doesn't go away with my provided solution above this edit, you can take a look at your dependencies and make sure they use Androidx as well.
EDIT 2
As #Ted mentioned, I researched back and he's right kapt does handle java files as well. kapt alone will do the trick, no need to keep both kapt and annotationProcessor dependencies.
Try removing this line:
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
from the buildscript / repositories section of your build.gradle file.
When I added that line, I got the error you described. When I removed it, no longer. That line should only be in the allprojects / repositories section.
Try set android.enableJetifier=false in gradle.properties. Then Invalidate Caches / Restart ... in Android Studio
The fix is in 4.2.0, use the higher version of google gms jar.
Try changing:
classpath 'com.google.gms:google-services:4.0.1'
by this version:
classpath 'com.google.gms:google-services:4.2.0'
Hope this works...
If you are using dagger or butterknife, please make sure to update it to the latest version. Or, if you have another injection library used in your project, you can try to check it if it support androidx or no.
I've found same error, the problem is on my dagger and butterknife. Have fixed it by updating it to newest version.
Android version: 4.10.2
I solved this issue with three simple steps:
First i added below this in pubspec.yml:
(with two spaces of identation)
module:
androidX: true
Adding this two lines below in gradle.properties, i have this in android/gradle.properties, in the project folder.
android.useAndroidX=true
android.enableJetifier=true
And after this i wrote with the terminal:
flutter clean
Maybe you will have to stop the device and run again.
I fixed this by updating the firebase dependencies to the latest.
I faced this error after adding butterknife to my project.
In order to resolve this error you should use Java8.
I would recommend this answer.
How I resolved it:
1.add following code in build.gradle (module: app)
android {
...
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
clean prject and run.
I fixed it by refreshing the cahche (Instead of invalidating it - which also clears the local history):
in gradle.properties file, comment the line org.gradle.caching=true.
Clean, Rebuild.
in gradle.properties file, un-comment the line
org.gradle.caching=true.
Clean, Rebuild.
Thats it!
Go to file and click on Invalidate caches and restart.
After it restarts then you increase the minimum SDK version in your app's build.gradle file.
While adding dependency implementation 'com.azoft.carousellayoutmanager:carousel:1.2.4' to my project, Android Studio throws exception Failed to resolve: recyclerview-v7. Then I tried adding dependency for recyclerview. Still getting same error.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.someapp"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-crash:16.0.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.3.1'
implementation 'com.commonsware.cwac:saferoom:0.4.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.support:cardview-v7:27.1.1'
}
apply plugin: 'com.google.gms.google-services'
I have same problem and i'm change order of repositories in biuld.gradle (app) and problem solved.
Change :
jcenter()
google()
To :
google()
jcenter()
Hope it's help
In Android Studio go to build.gradle (Project: YourProjectName), NOT the build.gradle (Module: app)
Change the code, so it looks like this (switch google() and jcenter()):
allprojects {
repositories {
google()
jcenter()
}
}
Add maven to repositories and it should work
I have no idea why. But my exact same problem has been solved with commenting all of android support dependencies.
It's so strange. But now my project runs without adding another version of these dependencies. When I put only one of these dependencies, I have a warning between ver 27.1.1 and 28.0.0 of support libraries. But I've only used version 28 on this project. It means there is all of these dependencies somewhere in the gradle which obviously is not written by me, or may be it's in the sth like cache (So strange bug).
implementation "com.android.support:support-v4:28.0.0"
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:support-vector-drawable:28.0.0"
implementation "com.android.support:recyclerview-v7:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation "com.android.support.constraint:constraint-layout:1.1.3"
If any of the above solutions did not work try to remove Maven repository and resync again.
this line in build.gradle
maven {
url "https://storage.googleapis.com/snap-kit-build/maven"
}
That's work for me in some projects.
Or replace this line
'com.android.support:recyclerview-v7:27.....'
With this line
'com.android.support:recyclerview-v7:28.0.0-alpha3'
That will solve your problem.
It cannot resolve because the version you are adding might not be in the Maven repository. Check your Api level and choose the appropriate version.
This link might be of help.
Finally I found a solution. Upgrading all the support dependencies to the latest version, solved the issue. You can check the latest version of dependencies here. I upgraded the support dependencies to the latest version 28.0.0-alpha3. It solved my problem.
I had the same error Failed to resolve: recyclerview-v7. Even though project worked before and I just moved it to another machine without changes in gradle files.
Full clear of gradle service folder helped me. By default it is located in C:\Users\username\.gradle
I closed Android Studio and deleted that folder. After that gradle made clean sync and it ended with success.
Maybe deleting of only cached libraries in C:\Users\username\.gradle\caches\modules-2\files-2.1\com.android.support\recyclerview-v7 would help but I didn't check it.
You have to exclude recyclerview-v7 module from the library you want to add:
compile ('YOUR_DEPENDENCY') {
exclude module: 'recyclerview-v7'
}
You have to use for example this dependency: implementation 'com.android.support:recyclerview-v7:28.0.0' in your build.gradle(Module: app) and use 'sync project with Gradle Files' then it will get this dependency. It should work then.
in androidx version I added implementation "androidx.recyclerview:recyclerview:1.1.0" to my gradle and it solved the issue
I am getting this error:
Here is my build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.mycompany.myapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding.enabled = true
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.firebase:firebase-core:15.0.0'
compileOnly "org.projectlombok:lombok:1.16.20"
annotationProcessor 'org.projectlombok:lombok:1.16.20'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services-places:15.0.0'
implementation 'com.paytm.pgsdk:pgsdk:1.0.8'
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'
compile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
}
apply plugin: 'com.google.gms.google-services'
and Here is my build.gradle(Project: myApp)
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'io.fabric.tools:gradle:1.25.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have checked other solutions, most of them suggest to add
maven { url "https://maven.google.com" }
to build.gradle of project. I have already tried this but I am still getting same error.
I am on android studio 3.0.
I have also tried adding google() instead of maven (another suggestion)
OPTION 1:
Follow the below instruction to resolve it.
Project-level build.gradle
use
maven { url "https://www.jitpack.io" }
instead of
maven { url "https://jitpack.io" }
OPTION 2:
Project-level build.gradle
google() repository should be 1st priority
allprojects {
repositories {
google()
mavenLocal()
jcenter()
}
}
OPTION 3:
Follow the below steps to resolve it.
Step1:
Project-level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "https://jitpack.io" } // For Ucrop
maven { url "https://maven.google.com" } // Google's Maven repository - FCM
maven {
url 'https://dl.bintray.com/azeesoft/maven'
}
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Step2:
App-level build.gradle
I have update One Signal version.
use
implementation 'com.onesignal:OneSignal:3.11.1'
instead of
implementation 'com.onesignal:OneSignal:3.10.9'
I had the same issue while use OneSignal to handle push notifications in my android application.
The solution is to add the exclude clause to its' dependency:
implementation ('com.onesignal:OneSignal:3.8.3'){
exclude group: 'com.google.android.gms'
}
in the app folder, then add any other missing dependency manually such as:
implementation 'com.google.android.gms:play-services-appinvite:16.1.0'
The problem is that OneSignal SDK contains Google Play Service dependency that are not of the same version with the latest version of gms and firesbase I used in the app.
So I suggest you figure out a dependency you added that uses google play service in the project and use the exclude clause on it. Though your gradle should build if your system is connected to the internet.
Hope this is helpful.
Go to File → Other Settings → Default Settings → Build, Execution, Deployment → Build Tools → Gradle → uncheck Offline work option.
I was using a VPN for internet connection. I closed VPN and it worked for me.
Using the VPN solved my problem.
I had this problem and I was using a proxy before. I figured out that my proxy is not working any more so i went to settings and changed the proxy config to Automatic but still the same error was being shown.
I finally found that the proxy was also automatically set to gradle as well but when I disabled it, it wasn't removed from my gradle config. so I went to C:Users/User/.gradle/gradle.properties and in that file there was something like this:
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#enter code here
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Aug 31 18:23:27 IRDT 2019
systemProp.https.proxyPort=8118
systemProp.http.proxyHost=fodev.org
systemProp.https.proxyHost=fodev.org
systemProp.http.proxyPort=8118
so I just edited this file and commented the last 4 lines and it solved my problem.
I am also using a VPN service.
My issue was...
I can run the project... but suddenly this error came up.
After few tried "Try Again" Solution but not solving.
Finally after few minutes wasted. I Try Clean Project. And Rebuild. Tadaaaa it work.
i dont know if this will help anybody but it solve my issue. hope it solve yours.
Open top-level build.gradle file and add google-services:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
also if you already have it added simply update google-service and gradle to the latest
If this problem occurred to you suddenly, it may be that it was corrupted while generating the apk. This rarely happens
Solution: rebuild tasks
you can see it in this image
An update of the repository to the latest version solved the problem for me.
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
In my case I just changes my just changes my project level build Gradle and other dependencies to the latest and the Google Maps dependency in app level build gradle to 10.0.0.
Just Build → Clean Project worked for me
Have you tried adding this in your dependencies:
implementation 'com.google.android.gms:play-services-basement:15.0.0'
I am developing a google map app using Android Studio. When I sync the project with Gradle Files (Select Tools/Android/Sync Project with Gradle Files on Android Studio), I get the following error:
Could not resolve com.google.android.gms:play-services-maps:11.6.2.
Couold not get resource 'https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-maps/11.62./play-services-maps-11.6.2.pom
This is the software I am using:
Android Studio 3.0.1
Android Version 7.1.1
Google Play Services 46
Google Repository 58 (under Support Repository)
I've tried using both the google maps project template and the empty activity project but I get the same error.
I am using the http proxy setup I used from earlier projects. I am able to install the play-services-maps and the google repository.
I also added the maven url to the Gradle Project file in the All Projects/Repositories section.
I have tried the suggestions from Stack Overflow but none have not worked.
Any ideas?
Gradle Project Build file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The gradle app build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "hansen.scott.googlemaps"
minSdkVersion 25
targetSdkVersion 26
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:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.6.2'
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'
}
The error is in the line:
implementation 'com.google.android.gms:play-services-maps:11.6.2'
try adding this in project level gradle file
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
}
}
Someone had the same issue I did and entered it on Stack Overflow a day or two ago. The user was getting a build error when using player-services-maps 11.6.2. If the user changed the version to 11.0.0, the build succeeded.
Once I back-dated the maps version to 11.0.0, this solved my problem too. I created a new Google Map project and didn't modify the Gradle Build files.
The problem appears to be that play-services-maps won't build using a versions after 11.0.0. I will post the issue on Github.
Thank you for everybody's help.
I have been facing the same issue for the past one week and posted it on Stack Overflow as well but to no effect.
I have since then figured out the root cause. I am working out of my office and thus have firewalls in place. I got it checked with the system admin and on turning off the firewall the build worked.
So i would advice you to have this checked as well.
Kind regards,
Kabir
I am unable to fix this error:
dependencies cannot be applied to '(groovy.lang.Closure)
This is my gradle file:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':FRNDzTER_core')
compile project(':cropper')
compile project(':stickyListHeaders')
compile "com.nostra13.universalimageloader:universal-image-loader:${rootProject.universalImageLoaderVersion}"
compile "com.google.android.gms:play- services:${rootProject.googlePlayServicesVersion}"
compile "de.keyboardsurfer.android.widget:crouton:${rootProject.croutonVersion}"
compile "com.nineoldandroids:library:${rootProject.nineoldandroidsVersion}"
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.crashlytics.android:crashlytics:1.+'
}
android{
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {
debuggable rootProject.prodDebug
proguardFile 'proguard.cfg'
}
}
dependencies {
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
}
You can go to Preferences and select "use default gradle wrapper" then rebuild the project. It worked well for me:
Go to
Windows
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
Mac
Preference -> Build, Execution, Deployment -> Build Tools -> Gradle
and select Use default gradle wrapper
Based on what Android Studio generates, you need to have a top-level project file build.gradle, and another for your app build.gradle.
Top-level:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
}
Application level:
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
android{
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {
debuggable rootProject.prodDebug
proguardFile 'proguard.cfg'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
} `
dependencies {
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':FRNDzTER_core')
compile project(':cropper')
compile project(':stickyListHeaders')
compile "com.nostra13.universalimageloader:universal-image- l loader:${rootProject.universalImageLoaderVersion}"
compile "com.google.android.gms:play- services:${rootProject.googlePlayServicesVersion}"
compile " "de.keyboardsurfer.android.widget:crouton:${rootProject.croutonVersion}"
compile "com.nineoldandroids:library:${rootProject.nineoldandroidsVersion}"
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.crashlytics.android:crashlytics:1.+'
}
But even without all that, your problem is that you have a dependencies within your android plugin config.
android {
dependencies {
}
}
remove that empty dependencies block.
EDIT: I also started getting this error with the latest Android Studio, all I had to do was add a newer version of the Gradle plugin, and compileSdkVersion 22.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
If you already are using the "default gradle wrapper" and it doesn't help:
In Menu click: File -> Invalidate Caches / Restart...
If it also doesn't help try in 2 steps:
1) Delete ".gradle" folder (and "build" folder if you have it already)
2) In Menu click: File -> Invalidate Caches / Restart...
After restarting the warning should disappear.
(For me it worked and for Android Studio and for IntelliJ Idea)
My problem is that the whole build.setting file were occupied with cannot be applied to '(groovy.lang.Closure)' warning messages instead of happening on any particular variable.
I have tried all solutions provided by others but none of them works for me.
I ended out doing these steps then it works like a charm. If you are encountering the same issue then give it a try.
Open and edit file: yourproject/gradle/wrapper/gradle-wrapper.properties. Edit content to update the gradle distribution version as shown in the image below then save.
Delete this folder: yourproject/.gradle.
Click Sync project with gradle files, then you are good to go.
I went into the preferences to try one of the other answers when I noticed a warning that my gradle home directory was wrong. So I opened up the file browser and chose the newer gradle version, and all the errors went away. Image shown below.
I bet you the problem is totally unrelated to the piece of code that is giving you warnings, most likely it's your proguard file. I had the following in my code and got the same warning:
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
By commenting out runProguard false, all of my problems go away, go figure :)
I have same problem in android studio 2.2,it work for me:
original:
android {
...
}
dependencies {
...
}
move dependencies in android:
android {
...
dependencies {
...
}
}
I solved the problem in Android Studio by Invalidating the cache and restart.
File-> Invalidate Caches / Restart..
I ran into a similar problem to this in IntelliJ for a Kotlin project. It looks like the issue was that in my project, even though it was set to use JDK 8, the language and API versions somehow got set to 1.3. See Project Preferences > Facets. In my case, I ticked "use project settings," but manually setting them per facet may work as well.
Close the project (File / Close project),
Select “Open an existing Android Studio project” on the start menu and select the folder that contains your Android project.
This work for me.
Gradle files can be made explicit in several places to avoid such errors. E.g. Change
configurations {
to
project.configurations {
or
task {
description 'foo'
to
task {
setDescription 'foo'
To fix the issue simply close the project, then select “Open an existing Android Studio project” on the start menu and select the folder that contains your Android project. Beware, select the folder, not the .iml project file.
Cut and then paste the "buildTypes" at the same place in "android" section and Re-Sync (refresh) Project
For people with M1 Intellij IDEA just add in build.gradle(:app)
//noinspection GroovyAssignabilityCheck
buildFeatures {
viewBinding
}
I fixed this issue with gradle 2.10.
Download it here : http://gradle.org/gradle-download/
And set your local gradle distribution like this :