Android Studio Error fail to establish apply plugin com.android.application - android-studio

Error:(1, 1) A problem occurred evaluating project ':app'.
Failed to apply plugin [id 'com.android.application']
Could not create plugin of type 'AppPlugin'.
Can anyone help me to solve this issue

Google releases a new build tool and old makes deprecated I think.
We used: classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
but new version was released and this error occured.
Just replace previous with new version:
classpath 'com.android.tools.build:gradle:2.1.0-alpha5'
So check latest build tool from: http://tools.android.com/tech-docs/new-build-system
Stable build tool last version is (I think): classpath 'com.android.tools.build:gradle:1.5.0'

Related

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

So I was building out a test APK in Android Studio tonight that had to be signed. It failed and said my Gradle was out of date. So I upgraded my gradle from 7.3.3 to the newest 7.5.1
I changed the wrapper setting to distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
and then I changed my build.gradle dependency to classpath 'com.android.tools.build:gradle:7.5.1'
Note that after doing the changes, and restarting Android Studio, it did upgrade the version in the app directory.
Here's the error getting thrown below:
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.5.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.5.1/gradle-7.5.1.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.5.1/gradle-7.5.1.pom
Required by:
project :
Note that this was a project from a client, and I did not write this originally. These dependencies were in place, but fairly recent, and the app would build fine with it using 7.3.3. However it wouldn't let me sign my app.
I suppose I could use some wisdom on both of these issues. What I'm going to do is go back to version 7.3.3, build the signed APK again, and copy that exact error to report back here with. It was a gradle version error.
For any any Flutter noobs like myself passing through, this error occured because the Android Tools Plugin version DOES NOT match the Gradle Version:
https://developer.android.com/studio/releases/gradle-plugin#groovy
They match up just vaguely enough in number, that you would think that my line com.android.tools.build:gradle:7.5.1. uses gradle 7.5.1, but instead, Android Tools for Gradle is actually a separate entity, and at 7.3.3 as of typing this reply.
So you CAN set your Gradle to the newest version somewhere else in your project, but it has to match the compatible Android Tools version, which is set here. Its silly and confusing at first, and can easily trip up newcomers. Hopefully the versions diverge enough, or the code syntax changes for some better clarity, but as of now, this is it.

groovy lang Missing Property Exception [duplicate]

After updating to Android Studio 4 I got this error:
A problem occurred configuring project ':app'.
groovy.lang.MissingPropertyException: No such property: scope for class: com.android.build.gradle.internal.variant.ApplicationVariantData
My gradle:
classpath 'com.android.tools.build:gradle:4.1.0-alpha10'
gradle-wrapper.properties:
https://services.gradle.org/distributions/gradle-6.5-bin.zip
I had the same issue. Removing all fabric references in build.gradle solved my case.
you can try to remove
apply plugin: 'io.fabric'
and
classpath 'io.fabric.tools:gradle:1.31.2'
lines from your build.gradle file.
Fabrics Crashlytics deprecated. If you are using Fabric Crashlytics you can replace it with Firebase Crashlytics.
I had the same problem, in particular with the the same stack trace as #display name (on the comments).
From there I noticed the reference to Crashlytics. And effectively that was the issue: the old, deprecated, version (from Fabric). Migrating to the new Firebase Crashlytics fixed the issue for me.
Update in OCTOBER 2020 :
Fabric is deprecated, so remove all plugins and dependencies depend on Fabric.io
like :
apply plugin: 'io.fabric'
classpath 'io.fabric.tools:gradle:1.31.2'
maven {
url 'https://maven.fabric.io/public'
}
and after deletaion you must add :
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
in your build.gradle.
https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android
Just remove or comment it out. it works for me.
apply plugin: 'io.fabric'
and
classpath 'io.fabric.tools:gradle:1.+'
from both gradle file.
Please update your Gradle dependency to:
classpath "com.android.tools.build:gradle:4.0.0"
and in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
This started happening for me when upgrading Android Studio from 4.0.2 to 4.1. Unfortunately, I had to update a branch that still includes fabric, the only way I could get it working was to downgrade android studio and make the fixes and be able to make a new build.
Download old versions here:
Windows: https://android-studio.en.uptodown.com/windows/versions
Mac: https://android-studio.en.uptodown.com/mac/versions
I am using Fabrics Crashlytics and i got the same error after updating my Android plugin for Gradle to version 4.1:
classpath 'com.android.tools.build:gradle:4.1.0-rc01'
I need to upgrade gradle plugin to upload native debug symbols to Google play console as stated in this link.
https://developer.android.com/studio/preview/features#native-crash-symbolization
To use Android plugin for gradle version 4.1,
your minimum gradle version needs to be version 6.5.
I used gradle version 6.5.1
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
Upgrading from Fabric Crashlytics to Firebase Crashlytics solved the issue for me, this could be because fabric is not compatible with the newer versions of Android plugin for gradle. For more information on how to upgrade from Fabric crashlytics to Firebase Crashlytics. Check out this link https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android
If you are using com.google.firebase:firebase-crashlytics-gradle dependency in your project, just update to version 2.0.0-beta04 it is helped to me.
Remove all that connected with deprecated library such as fabric crashlytics etc.
Updating dependencies in build.gradle (Project level) solved my issue:
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.0'
I updated the de.mannodermaus.gradle.plugins:android-junit5 to the latest version
I run into this problem with an older project which I was maintaining after a longer period. Problem was that project was still using older gradle scripts, plugins and dependencies.
The biggest problem was fabric.io which is not maintained and compatible with the latest gradle version. Stack trace in build output which contained crashlytics references pointed me to the fabric. I recommend checking it. In your case, it might be related to other plugins.
Stack trace example:
at com.crashlytics.tools.gradle.ProjectVariantState$deriveFrom.call(Unknown Source)
at com.crashlytics.tools.gradle.CrashlyticsPlugin.createTaskBuilder(CrashlyticsPlugin.groovy:301)
at com.crashlytics.tools.gradle.CrashlyticsPlugin.this$2$createTaskBuilder(CrashlyticsPlugin.groovy)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.crashlytics.tools.gradle.CrashlyticsPlugin.addPluginTasks(CrashlyticsPlugin.groovy:271)
In Project level build.gradle Just downgrade the version of dependency 'com.android.tools.build:gradle:4.5.0' to your last/lower version was 'com.android.tools.build:gradle:4.0.1' and
In "gradle-wrapper.properties" downgrade the "distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip" to last/lower version like "distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip" .
and sync and run .
On Android Studio simply open build.gradle (Project) and the IDE should suggest an update to crashlytics, accept that and the error will be gone.

org.gradle.tooling.model.UnsupportedMethodException: Unsupported method: AndroidArtifact.getBuildConfigFields()

I was building my android project on Android Studio 4.2.1.
but I get this error:
org.gradle.tooling.model.UnsupportedMethodException: Unsupported method:
AndroidArtifact.getBuildConfigFields().
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.
my Gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
my Gradle plugin tools version:
com.android.tools.build:gradle:4.1.0-alpha09
The both Gradle and Gradle plugin are the latest versions. The exception says that I need to update/change the connected Gradle version.
I am impossible to upgrade further version because I am already on the latest version. So, the only thing I can do is changing the grade version, but which one?
I was able to build project successfully by using :
classpath 'com.android.tools.build:gradle:4.0.0'
But if you are trying to use jetpack compose you will have to use latest canary version of android studio.

Gradle build error: Gradle DSL method not found: 'uildscript()'

Hey I am getting this error while running the app. Please can someone tell me how to fix it?
Error:(1, 0) Gradle DSL method not found: 'uildscript()' Possible
causes:The project 'ePulse2' may be using a version of Gradle
that does not contain the method. Open
Gradle wrapper fileThe build file may be missing a Gradle
plugin. Apply Gradle plugin
You have a typo: change uildscript to buildscript. Here are the docs.

Android studio preview 0.4.5: The project is using an unsupported version of the Android Gradle plug-in

I got the following error message when I was importing a project from github:
Failed to refresh Gradle project 'XXX'
The project is using an unsupported version of the Android Gradle plug-in.
Fix plug-in version and re-import project
This is not a duplicate of this because your get thee error message before
gradle/wrapper/gradle-wrapper.properties
is generated.
The problem appeared after updates. The updated Android Gradle plug-in did not support the outdated version of Gradle I had. But the error message is misleading, if you don't attempt different build options you won't see what the problem is.
After downloading a newer version of Gradle, Imported the project again, then:
Use local gradle distribution
Then Gradle home set to the folder where the new version of gradle was downloaded
that solved it
Edit: From Scott (below comments) : It's preferable to use the wrapper and to change the Gradle version in gradle-wrapper.properties instead of downloading and installing Gradle yourself. As for the Android-Gradle plugin, that's set in the dependencies.classpath block in your build file; see this
I get this gradle-errors in 4 Studio updates! My solution: I copy the Studio-folder, and if gralde throws an error, I copy the old version back. It's not a good way, but until google is not able to deliver an update without producing always the same errors (even if mentioned in many forums), I stay on 4.9 and wait for the first final release.

Resources