gradle project sync failed even after upgrading gradle plugin - java

Gradle project sync failed and did not get answers from other related questions. Here are the details of my situation.
Initial sync attempt yielded the following error message:
Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I have Android Studio 3.0. The build.gradle file includes the following dependency:
classpath 'com.android.tools.build:gradle-experimental:0.2.1'
The gradle-wrapper.properties file includes the following distribution URL:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
According to https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle I need to make some changes.
First, update the Gradle version for Android Studio 3.0 in gradle-wrapper.properties:
distributionUrl=\
  https://services.gradle.org/distributions/gradle-4.1-all.zip
(I believe the backslash right after the equal sign is an error and did not make that change.)
Second, add the following buildscript repository to build.gradle:
google()
Third, change the build.gradle dependency:
classpath 'com.android.tools.build:gradle:3.0.1'
The second and third changes apply the latest version of the Android plug-in.
When I try to sync after these changes it fails again with the following new error:
Plugin with id 'com.android.model.application' not found.
The error refers to the first line of build.gradle:
apply plugin: 'com.android.model.application'
What is happening and why? I recently added NDK to Android Studio. The project I'm trying to sync includes C code. I'm not completely certain I added NDK correctly. I wonder if that could be part of the problem.

First, the gradle-wrapper.properties is incorrect. You must include \ in it. It should be something like this:
#Sat Jun 17 17:47:18 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Then, add the experimental classpath to project build.gradle. Something like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle-experimental:0.7.0-alpha4"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Check the Experimental Plugin User Guide for details.

Go to your build.gradle version or update it
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}

You should change you dependencies classpath
All steps are here :
Open build.gradle and change the gradle version to the recommended version:
classpath 'com.android.tools.build:gradle:1.3.0' to
classpath 'com.android.tools.build:gradle:2.3.2'
Hit 'Try Again'
In the messages box it'll say 'Fix Gradle Wrapper and re-import project' Click that, since the minimum gradle version is 3.3
A new error will popup and say The SDK Build Tools revision (23.0.1) is too low for project ':app'. Minimum required is 25.0.0 - Hit Update Build Tools version and sync project
A window may popup that says Android Gradle Plugin Update recommended, just update from there.
Now the project should be runnable now on any of your android virtual devices.

Make sure your Gradle version is compatible with your Android Gradle Plugin.
https://stackoverflow.com/questions/24795079
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

Related

im getting build error after connecting firebase with my code [duplicate]

I have just started a new project and am trying to connect to Firebase.
As soon as I try to build my project I got the error:
Could not parse the Android application Module's Gradle Config
So I looked in my build which told me that jCenter() was deprecated and that I should remove it. When I removed it, everything worked fine. However, when I tried to connect to Firebase I got the error:
AbstractDynamicObject$CustomMessageMissingMethodException.
What may be causing this?
Full stack trace:
Caused by: java.lang.RuntimeException: com.android.build.gradle.internal.crash.ExternalApiUsageException: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method setVariantDir() for arguments [debug] on task ':app:processDebugGoogleServices' of type com.google.gms.googleservices.GoogleServicesTask.
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:71)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:54)
at com.android.build.gradle.internal.profile.AnalyticsResourceManager.recordBlockAtConfiguration(AnalyticsResourceManager.kt:206)
at com.android.build.gradle.internal.profile.AnalyticsConfiguratorService.recordBlock(AnalyticsConfiguratorService.kt:85)
at com.android.build.gradle.internal.plugins.BasePlugin.lambda$createTasks$9(BasePlugin.java:582)
at com.android.build.gradle.internal.crash.CrashReporting$afterEvaluate$1.execute(crash_reporting.kt:37)
at com.android.build.gradle.internal.crash.CrashReporting$afterEvaluate$1.execute(crash_reporting.kt)
I came here because I am getting the same error. Luckily I was updating dependencies when it happened and narrowed it down to:
classpath 'com.google.gms:google-services:4.3.6'
Change it to
classpath 'com.google.gms:google-services:4.3.5'
The error goes away for me. Hopefully for you too
Here is more info on my dependencies.
Running Android Studio 4.2 build April 28 2021
repositories {
google()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.0'
classpath 'com.google.firebase:perf-plugin:1.4.0'
Gradle Plugin 4.2.0
Gradle 7.0.1
//Firebase
implementation 'com.google.firebase:firebase-ads:20.1.0'
implementation 'com.google.firebase:firebase-core:19.0.0'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
implementation 'com.google.firebase:firebase-auth:21.0.0'
implementation 'com.google.firebase:firebase-firestore:23.0.0'
Update : Google has just fixed the problem in version 4.3.8 (Release Notes)
An updated version of the google-services plugin for Android (v4.3.8) is now available. For more information, see the Firebase Android SDK Release Notes.
The error came from classpath 'com.google.gms:google-services:4.3.6'
The easiest solution :
Go back to version 4.3.5
dependencies {
classpath 'com.google.gms:google-services:4.3.5'
}
Instead of 4.3.6
dependencies {
classpath 'com.google.gms:google-services:4.3.6'
}
In fact, version 4.3.6 is responsible for this error. The easiest
way is to go back to the previous version until it is fixed
Caused by: java.lang.RuntimeException:
com.android.build.gradle.internal.crash.ExternalApiUsageException:
org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException:
Could not find method setVariantDir()
Fixed bug
You should use the latest possible version.
DO
dependencies {
classpath 'com.google.gms:google-services:4.3.8'
}
Addition to RRiven fix,
I started getting error Plugin with id ‘maven’ not found after RRiven fix.
I fixed it with downgrading gradle version to 6.9 from file -> project structure -> project -> gradle version
Set Code in build.gradle(Project)
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.google.gms:google-services:4.3.5'
Set Line in gradle-wrapper
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Best way. Google has resolved it.
classpath 'com.google.gms:google-services:4.3.8'
Go to the latest version now of 4.3.8
https://developers.google.com/android/guides/releases
https://firebase.google.com/support/release-notes/android#google-services_plugin_v4-3-8
In Kotlin, Gradle version 7.3.3
1- build.gradle (Project)
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2- build.gradle (Module)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
id 'com.google.gms.google-services'
}

Configuration with name 'default' not found gradle sync failed [duplicate]

I have an Android Studio app. It has a library dependency (Android-Bootstrap), when I try to sync gradle, it gives me an error:
Configuration with name 'default' not found.
My structure is:
-FTPBackup
-fotobackup
-build.gradle
-Libraries
-Android-Bootstrap
-Settings.gradle
-build.gradle
-Settings.gradle
-Build.gradle
The FTPBackup settings.gradle and build.gradle:
include ':fotobackup'
include ':libraries:Android-Bootstrap',':Android-Bootstrap'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
And the build.gradle inside fotobackup is:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:+'
compile project (':libraries:Android-Bootstrap')
}
The library is downloaded from https://github.com/Bearded-Hen/Android-Bootstrap and it has build.gradle, settings etc.
whats wrong?
For one, it doesn't do good to have more than one settings.gradle file -- it only looks at the top-level one.
When you get this "Configuration with name 'default' not found" error, it's really confusing, but what it means is that Gradle is looking for a module (or a build.gradle) file someplace, and it's not finding it. In your case, you have this in your settings.gradle file:
include ':libraries:Android-Bootstrap',':Android-Bootstrap'
which is making Gradle look for a library at FTPBackup/libraries/Android-Bootstrap. If you're on a case-sensitive filesystem (and you haven't mistyped Libraries in your question when you meant libraries), it may not find FTPBackup/Libraries/Android-Bootstrap because of the case difference. It's also looking for another library at FTPBackup/Android-Bootstrap, and it's definitely not going to find one because that directory isn't there.
This should work:
include ':Libraries:Android-Bootstrap'
You need the same case-sensitive spec in your dependencies block:
compile project (':Libraries:Android-Bootstrap')
compile fileTree(dir: 'libraries', include: ['Android-Bootstrap'])
Use above line in your app's gradle file instead of
compile project (':libraries:Android-Bootstrap')
In my setting.gradle, I included a module that does not exist. Once I removed it, it started working. This could be another way to fix this issue
If you're getting this error with react native, it may be due to a link to an NPM package that you removed (as it was in my case). After removing references to it in the settings.gradle and build.gradle files, I cleaned and rebuilt and it's as good as new :)
Just a note on this question:
I had this exact error in my React Native app when trying to build to android. All you should have to do is $ npm i.
Case matters
I manually added a submodule :k3b-geohelper
to the
settings.gradle file
include ':app', ':k3b-geohelper'
and everthing works fine on my mswindows build system
When i pushed the update to github the fdroid build system failed with
Cannot evaluate module k3b-geohelper : Configuration with name 'default' not found
The final solution was that the submodule folder was named k3b-geoHelper not k3b-geohelper.
Under MSWindows case doesn-t matter but on linux system it does
I had this issue with Jenkins. The cause: I had renamed a module module to Module. I found out that git had gotten confused somehow and kept both module and Module directories, with the contents spread between both folders. The build.gradle was kept in module but the module's name was Module so it was unable to find the default configuration.
I fixed it by backing up the contents of Module, manually deleting module folder from the repo and restoring + pushing the lost files.
The message is a known Gradle bug. The reason of your error is that some of your gradle.build files has no apply plugin: 'java' in it. And due to the bug Gradle doesn't say you, where is the problem.
But you can easily overcome it. Simply put apply plugin: 'java' in every your 'gradle.build'
I also faced the same problem and the problem was that the libraries were missing in some of the following files.
settings.gradle, app/build.gradle, package.json, MainApplication.java
Suppose the library is react-native-vector-icons then it should be mentioned in following files;
In app/build.gradle file under dependencies section add:
compile project(':react-native-vector-icons')
In settings.gradle file under android folder, add the following:
include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
In MainApplication.java, add the following:
Import the dependency: import com.oblador.vectoricons.VectorIconsPackage;
and then add: new VectorIconsPackage() in getPackages() method.
I am facing same problem, I was fixed it by generating gradle project and then adding lib project to android studio
First, See build.gradle file is present in project root directory
if not then, Create gradle project,
export your required lib project from eclipse then (File->Export->Android->generate Gradle build file
Click on Next->Next->Select your lib project from project listing->Next->Next->Finish
See build.gradle file present in your project root directory
Move this project to Android Studio
Your module name must be camelCase eg. pdfLib. I had same issue because I my module name was 'PdfLib' and after renaming it to 'pdfLib'. It worked.
The issue was not in my device but in jenkins server. So, check and see if you have such modulenames
Step.1
$ git submodule update
Step.2
To be commented out the dependences of classpass
You are better off running the command in the console to get a better idea on what is wrong with the settings. In my case, when I ran gradlew check it actually tells me which referenced project was missing.
* What went wrong:
Could not determine the dependencies of task ':test'.
Could not resolve all task dependencies for configuration ':testRuntimeClasspath'.
Could not resolve project :lib-blah.
Required by:
project :
> Unable to find a matching configuration of project :lib-blah: None of the consumable configurations have attributes.
The annoying thing was that, it would not show any meaningful error message during the import failure. And if I commented out all the project references, sure it let me import it, but then once I uncomment it out, it would only print that ambiguous message and not tell you what is wrong.

Could not find com.android.tools.build:gradle:2.2.2

A friend of mine copy pasted a libgdx project folder on his pc and sent the project to me(through google drive). We are both using Android Studio. I downloaded and imported the project and it is working properly on the emulator. However it is not working on the desktop. On his pc, it works both in desktop and in the emulator.
When I try to run it in the desktop, Android Studio gives me this error message:
Error:Gradle: A problem occurred configuring root project 'bouncerGDX - Copy'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:2.2.2.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar
Required by:
:bouncerGDX - Copy:unspecified
How can I fix this? I have no experience with Gradle.
UPD:
It seems can't resolve com.android.tools.build:gradle:2.2.2 dependency for the classpath.
For me, adding the jcenter to build.gradle resolves the issue:
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
or, alternatively, the line in build.gradle
classpath 'com.android.tools.build:gradle:2.2.2'
can be changed to
classpath 'com.android.tools.build:gradle:2.1.3'
^^^ this version exist in repo1.maven.org
WRONG SUGGESTION:
Resolve all dependencies by running gradle task (can be done from Android Studio's terminal):
For Linux:
./gradlew buildDependents
For Windows:
gradlew.bat buildDependents
Also, this commands might also help later
Linux:
./gradlew cleanIdea idea
Windows:
gradlew.bat cleanIdea idea
This is the reference to libgdx How-to-setup-development-env instruction
I was getting the same issue after updating Android Studio 2.2.2 to 2.3.1
Could not find com.android.tools.build:gradle:2.2.2.
Solution:
Open the gradle location and make changes in build.gradle accordingly(module and project both)
I replaced
classpath 'com.android.tools.build:gradle:2.2.2'
with
classpath 'com.android.tools.build:gradle:2.3.1'
And gradle build successfully :-)
gradle location
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
add google() below jcenter(),this works for me
Seems like you hav dependency on the library project bouncerGDX
You can open build.gradle of that project and change gradle version which is available with you. e.g.
classpath 'com.android.tools.build:gradle:2.1.0'
My fix for the same error was to configure Android Studio for the proxy I'm stuck behind.
Android Studio + Gradle did not assume system proxy settings, at least not on my copy of macOS. Set your proxy settings in Preferences > Appearance & Behavior > System Settings > HTTP Proxy, save them and restart Android Studio. It then prompted me to set Gradle's proxy settings to match Android Studio's. Once I did this, no more error.
Adding the maven url solved the issue for me.
buildscript {
repositories {
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
[Solution For Android 2.3.1 built in 2017 April]
In gradle.build(Project)
Add missing repositories
mavenLocal() and jcenter()
To
buildscript { repositories { }}
Notice there are TWO gradle.build files!! Pick the right one.
In my case I was updating Gradle as Android Studio recommended
Solution:
When you import the project make sure not to update Gradle (click "Don't remind me again for this project") and it should work.
Note: Use latest gradle version.

Why Error:(17, 0) Plugin with id 'com.android.library' not found?

I created a test project and add the library.
In the process of implementing it in my project I needed to add a line in build.gradle atmodule in dependencies, just such a line
compile project (':library')
And then added to the settings.gradle
include ':library', ':app'
and build.gradle atProject changed its classpath on
classpath 'com.android.tools.build:gradle:1.2.3'
and all was good!
Once it's working, I tried to implement this library in the main project and carried out the same steps as in the first case, but got an error that I do not know how to fix. What have I done wrong?
I have tryed find how to solve it in google and have tryed add some lines in my gradle like this
buildscript {
repositories {
mavenCentral()
}
And have tryed change number of tools version on 1.5.0 , but without success... What i am doing wrong? Help me

Update Android Studio Gradle plugin to last version

I'm new to Android developpement and I tried to install the Facebook SDK in my Android Studio project.
Then, I have a bug in build.gradle :
Error:(111, 0) Cannot call getBootClasspath() before setTargetInfo() is called.
So I searched for a solution and I found this on the stack:
This is a known issue , which is fixed by updating gradle to :
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
}
So I tried this but then I got the error:
Error:Could not find com.android.tools.build:gradle:1.1.2.
Searched in the following locations:
file:/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle/1.1.2/gradle-1.1.2.pom
file:/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle/1.1.2/gradle-1.1.2.jar
Required by:
Yoki:facebook:unspecified
So I moved into the specified directory and then there is only this:
$> ls
1.0.0 1.1.0
$> pwd
/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle
How can I update the gradle plugin?
Change your buildscript block. You have to specify also in this block the repositories.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
}
}
Also you can use the last version:
classpath 'com.android.tools.build:gradle:1.1.3'
There are three type of dependency in Android gradle file.
1. Module dependency: other local project.
2. Local dependency: in your sdk path extras folder.
3. Remote dependency: JCenter, MavenCenter or third party maven path.
'com.android.tools.build:gradle' is local dependency, so you have to check your sdk and update.
P.S. If you tired with the version issue, you can try andle.
It's an open source project to update your Android dependency version automatically.
See https://github.com/Jintin/andle for more information

Categories

Resources