FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle.
> Could not configure services using GradleScopeCompileServices.configure().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
This is my build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I tried so many things I changed flutter and gradle version and looked everywhere but I still get this error. It worked before now it just doesen't. Btw java version is set to 1.8
Faced the same issue.
Solution:
Downgrade flutter version from 2.2.3 to 2.2.2
Delete ~/.android folder.
Restart android studio.
That kind of error has like a hundreds reason no one can know except to remember what you had done before. But anyway for better solution follow the following:
go to tools tab then flutter clean
go to file tab then invalidate cache and restart
follow the steps in this article to have the latest updates from Gradle
finally go to android folder then build gradle then on top right you will see edit file or something similar .. press on it and open new window and let it auto update till the end .. and better if you go to file into that new window then select project structure and manually see what the warning will it show to you and only press update
And don't forget to use the latest Flutter SDK.
Related
I was able to build and publish my flutter app on October 6th, I returned today on Octuber 30th and I am getting this build error:
Could not resolve io.grpc:grpc-core:[1.28.0].
Could not HEAD 'https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml'.
Read timed out
It seems there is an issue with cloud_firestore somehow it's still trying to read from jcenter which I am informed that it's down and not supporting new repositories, but the issue is that I have not changed a single line nor updated any packages since my last publish and build, what caused this issue?
I remember I had a similar issue a few months ago but everything was fixed after I replaced jcenter with mavenCentral, but this time it's back again.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve io.grpc:grpc-core:[1.28.0].
Required by:
project :app > project :cloud_firestore > com.google.firebase:firebase-firestore:21.7.1 > io.grpc:grpc-android:1.28.0
project :app > project :cloud_firestore > com.google.firebase:firebase-firestore:21.7.1 > io.grpc:grpc-okhttp:1.28.0
> Failed to list versions for io.grpc:grpc-core.
> Unable to load Maven meta-data from https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml.
> Could not HEAD 'https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml'.
> Read timed out
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 37s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
This is my build.gradle:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Yes, my app is pretty old, since I have yet to update to null-safety.
Any tips to avoid this issue in the future?
How do I solve this current issue?
Same to me
Could not HEAD 'https://jcenter.bintray.com/com/stripe/stripe-android/maven-metadata.xml'.
> Read timed out
It seems that there is an issue with JCenter. It should be available, although it was changed to read only.
See also https://updownradar.com/status/jcenter.bintray.com
And I don't expect solutions on Sunday ;) So just wait till tomorrow.
Regarding JFROG:
UPDATE 4/27/2021: We listened to the community and will keep JCenter as a read-only repository indefinitely. Our customers and the community can continue to rely on JCenter as a reliable mirror for Java packages.
(Source https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/)
It seems Jcenter was just down, as per https://developer.android.com/studio/build/jcenter-migration the website will continue to provide read-only repositories indefinitely.
I pulled a team's project that is made in Flutter from Git and for some reason when building the app (pressing the green arrow in Android Studio and running main.dart) I get the following message:
What went wrong:
Execution failed for task ':biometric_storage:kaptGenerateStubsDebugKotlin'.
> Could not resolve all files for configuration ':biometric_storage:kapt'.
> Failed to transform moshi-1.13.0.jar (com.squareup.moshi:moshi:1.13.0) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for JetifyTransform: C:\Users\UserName\.gradle\caches\modules-2\files-2.1\com.squareup.moshi\moshi\1.13.0\da685586facab9eb5c4fb630ce248be14e7da21b\moshi-1.13.0.jar.
> Failed to transform 'C:\Users\UserName\.gradle\caches\modules-2\files-2.1\com.squareup.moshi\moshi\1.13.0\da685586facab9eb5c4fb630ce248be14e7da21b\moshi-1.13.0.jar' using Jetifier. Reason: Unsupported class file major version 60. (Run with --stacktrace for more details.)
My build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
classpath 'com.google.gms:google-services:4.3.5'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext.kotlin_version = '1.4.31'
My gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Other maybe relevant info
Fluter Android Studio plugin 63.2.1
Dart Android Studio plugin 203.8452
Dart 2.15.1
Flutter 2.8.1
Nobody on my team gets this message so I suspect It has to do with some local configuration difference or maybe I have a different version of some program. Also, I can't update Gradle because that causes some other problems.
EDIT: After clearing the cache all of my teammates, got this error.
NOTE: I am the one who asked this question. The following solutions are independent and you can try just one of them or you can combine them. Choose the one that looks simpler and if that works then there is no need for the other ones.
SOLUTION 1
Try ignoring that one .jar that is causing the problem. You can do this by editing file "gradle.properties". Add android.jetifier.blacklist or android.jetifier.ignorelist (LINK TO RELATED QUESTION) depending on the version of Android Gradle plugin version that you are using (to check which version you use, go to your build.gradle and check com.android.tools.build:gradle:X.Y.Z ). If you use anything before 7.0.0 use android.jetifier.blacklist and after use android.jetifier.ignorelist.
I use 3.6.0 so for me android.jetifier.blacklist works and android.jetifier.ignorelist does not.
SOLUTION 2
Try updating gradle and android gradle plugin to version 7. I did not try this and I can't because this isn't my personal project, but if you can go for it. Why I think upgrading will help? Well this github issue talks about that.
SOLUTION 3
The following solution doesn't make any sense (at least to me, if someone can explain why this fixes the problem please do), but for some strange reason it works.
I add a new library called bye-bye-jetifier because my idea was that I should turn off jetifier. Prior to turning it off I have to check if I have any dependence that uses outdated code (the code that is not AndroidX) hence I decided to install bye-byte-jetifier. After installing my build.gradle looked like this. After running with the following config the problem was gone.
buildscript {
repositories {
google()
jcenter()
mavenCentral() // <--------- I added this
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.dipien:bye-bye-jetifier:1.2.1' // <--------- I added this
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext.kotlin_version = '1.4.31'
Note that I didn't even apply the plugin (like the offical guide on bye-bye-jetifier says), that makes this solution even more confusing.
file: "gradle.properties" (Project Properties)
adding line below
android.jetifier.blacklist = com.squareup.moshi
You can also exclude moshi library from all the project
Write this in build.gradle(app)
configurations.all { exclude group:"com.squareup.moshi" }
Use carefully only when you know you don't use this library!
[enter image description here][1]I have a problem with two libraries, one shows as this "C:\src\flutter.pub-cache\hosted\pub.dartlang.org\path_provider_macos-2.0.0\lib" and the other one is "C:\src\flutter.pub-cache\hosted\pub.dartlang.org\shared_preferences_macos-2.0.0\lib", they appear in red line like this picture, i've uninstalled and installed back Android Studio, i also copy the config from a "new flutter project" to my actual project, i also managed to upgrade the other libraries by using other tutorials, but i cant install this two libraries yet, on top of that, each time i press the play button on android studio to start installing my app to my phone, this error appears:
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.github.agorabuilder:native-full-sdk:3.4.2.
Required by:
project :app > project :agora_rtc_engine
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 23s
Exception: Gradle task assembleDebug failed with exit code 1```
[1]: https://i.stack.imgur.com/wNXhP.png
Try this :
clean project
rebuild project
file/ Invalidate caches / restart
In the project-level build.gradle file of your android project add the following repository "maven { url 'https://jitpack.io' }" It should look similar to this
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
centre()
maven { url 'https://jitpack.io' }
}
}
allprojects {
repositories {
google()
centre()
maven { url 'https://jitpack.io' }
}
}
I am getting this error when i am trying to get the release apk of my app.
Below are all the data.
Console log
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\pro\food\android\build.gradle' line: 30
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> org.gradle.api.file.ProjectLayout.directoryProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/DirectoryProperty;
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
Picked up _JAVA_OPTIONS: -Xms256m -Xmx2048m
Running Gradle task 'assembleRelease'... 4.5s
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1
android level build.gradle file
buildscript {
repositories {
maven{url 'https://dl.google.com/dl/android/maven2'}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2.'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
maven{
url 'https://maven.gppgle.com'
}
google()
jcenter{ url "http://jcenter.bintray.com/"}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper properties
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3.2-all.zip
I have tried clearing the caches, restarting android studio.
Someone please help me with this issue.
Any kind of help will be appreciated.
Open your build.gradle file in android folder. (not in app)
inside dependency block, update classpath of tools.build.gradle like this,
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
}
I recently added one new library to my flutter app. It started showing me an error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUİLD FAILED in 14s
try to go to the dependencies and change the compile to 1.0.1
Step 1. Go to gradle.properties under android folder, and add the following piece of code:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Step 2. Now go to build.gradle under android and not under the app->build.gradle. While looking into the file make sure it starts with the word builscript (In this way you can ensure you're at the right build.gradle file.)
Step 3. Ctrl+A everything in that file, note that ctrl+A everything you need to erase off all the content and paste this piece of code:
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}
}
}
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
A very important point to note is that during the process of compilation, chances are that you will see this warning message in complete red. Please don't get scared of it and let the whole compilation complete, before jumping to any conclusions. Although it comes in red, it won't stop your compilation as you will see in the bottom a turning circle that will show the progress of compilation. Right after that, it will disappear and you will be able to run the App. Here's the warning message:
Note:
C:\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.11\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java
uses or overrides a deprecated API. Note: Recompile with
-Xlint:deprecation for details. Note: C:\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.11\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java
uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}' Note:
C:\flutter.pub-cache\hosted\pub.dartlang.org\mlkit-0.15.0\android\src\main\java\com\azihsoyn\flutter\mlkit\MlkitPlugin.java uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details.
And Boom! that's it. Trust me this will definitely solve your problems.
In case you still struggle with any such problems try to implement some of the other solutions mentioned in this link as well.