When i am trying to run my flutter app it getting an Error running gradle - gradle

i am getting an error when i trying to run the app. please help. The error in cmd is below -
Error running Gradle:
ProcessException: Process "C:\Flutter projects\FlatApp-Firebase-Flutter-master\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Flutter projects\FlatApp-Firebase-Flutter-master\android\app\build.gradle' line: 14
What went wrong:
A problem occurred evaluating project ':app'.
ASCII
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 14s
Command: C:\Flutter projects\FlatApp-Firebase-Flutter-master\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
line nine in app-build-gradle is below-
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

There could be many reasons for such a error. I had a similar error. I would suggest you to open your project in android studio and check your gradel versions. I see by the name of you app that you are using firebase. Some of those plugins use Androidx. So migrating your project to Androidx might help. Here's how to migrate your project to Androidx.
Hope it helps!

I had the same issue this may because of the incompatibility of Gradle versions.
I opened the android part in Android Studio and updated Gradle as recommended by Android Studio with Alt+Enter and it solved my problem.
I can elaborate more if you can post more details about it e.g your app/gradle file.

Related

Could not create service of type ChecksumService using BuildSessionScopeServices.createChecksumService()

I am new in gradle and when I try to simple check gradle built in tasks, I get Build Failed error.
Can anybody explain what is wrong?
I only run 'gradle tasks' on cmd and get next error:
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type ChecksumService using BuildSessionScopeServices.createChecksumService().
> Timeout waiting to lock checksums cache (M:\.gradle\checksums). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 14372
Owner Operation: unknown
Our operation:
Lock file: M:\.gradle\checksums\checksums.lock
* 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 1s
./gradlew --stop as the error happens when gradle didn't close cleanly. Such as in: Cannot lock checksums cache (/Users/.../StudioProjects/android/.gradle/7.4.2/checksums) as it has already been locked by this process.
This was a permissions issue for me.
I tried running a project on my Mac from my mounted Google Drive directory and got this error.
Moving the project to Documents worked.
FWIW, I forgot to stop the server in IntelliJ and once I did the problem went away.
For Flutter users
I faced this problem on Mac OS Monterey (M1 processor)
I solved it in the following way
Browse android/buil.gradle add or update gradle version to 7.1.2
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'. //---this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Update distributionUrl in android/gradle/wrapper/gradle-wrapper.properties to 7.4
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
Navigate in the terminal to the android folder and run
cd android
despues
./gradlew --stop
4.Run flutter clean and flutter pub get
flutter clean
flutter pub get
Then run flutter run
flutter run
This work for me:
Close my IDE
Go to my project directory
Search and delete all .lock files
Open the IDE, and try again
Just restart your machine. it's a cache related error

Minecraft Forge Gradle with VSCode

I am trying to create a Minecraft Mod using VSCode as this is my main editor for school, but when I try to run the command gradlew genVSCodeRun I get the follwoing output that says successful, but also "Could not resolve: net.minecraftforge:forge:1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3". When I then run gradlew build, the following it output:
Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
Could not find net.minecraftforge:forge:1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.
Searched in the following locations:
- file:/C:/Users/eabla/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.15.2-31.1.0_mapped_snapshot_20200119-1.15/forge-1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- file:/C:/Users/eabla/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.15.2-31.1.0_mapped_snapshot_20200119-1.15/forge-1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://libraries.minecraft.net/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://repo.maven.apache.org/maven2/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- https://repo.maven.apache.org/maven2/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
Required by:
project :
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 40s
1 actionable task: 1 executed
Any idea what this could be? I have done a fresh install of java JDK and JRE as well as a fresh install of the Forge MDK.
Your Forge Library is missing. Run the command gradlew eclipse after navigating into your project directory. It may take some time but it will surely fix it. :D
Make sure you have the JDK (java development kit https://www.oracle.com/java/technologies/javase-jdk8-downloads.html) installed not just the JRE

Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ on generate APK

My project is run on AVD properly. but when i try to generate signed APK, gradle get this error:
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
> Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
* 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
I've used this command many times: gson.fromJson. but i can't find error source. (which file and which line).
So how do I find the source of the error
I got this problem in Android Studio 4.0 when I did a Gradle sync. I fixed it by doing the following:
Open top-level build.gradle and change the gradle classpath to:
classpath 'com.android.tools.build:gradle:4.0.0'
Open gradle\wrapper\gradle-wrapper.properties and change the distribution URL to:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Copy in .idea\jarRepositories.xml from a new project
No idea how or why, but it worked for me
I got this error in Android Studio 4.0 when I did a Gradle sync after switching branches. I fixed it by doing this:
Build -> Clean Project
Sync Project with Gradle files
I had the same problem when I tried to build a "signed release APK". I was using Android Studio Beta 4.0.
To fix the problem, I've upgraded to Beta 4.0 v4 and it resolved the problem.
i changed the place where my APKs generated inside and it's working fine now

Android studio build error

Tried to create my first project in android studio, using one of the examples im trying to run the application, but gradle gives me this build error (didnt change one line of code - just trying to run the Empty activity):
Gradle: FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':Passivelocation:packageDebug'.
org.bouncycastle.asn1.ASN1Integer.(J)V
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Ive tried adding info and debug while running the command on with the cli but i cant make much of the output it gives me.
Any suggestions?
I faced the same failure and the problem was with my jdk/jre because some time ago I added the Bouncy Castle Crypto APIs functionality by adding the jar to my jdk/jre path.
I tried a gradle build with a "clean" jdk/jre and problem was solved

Android Studio Compilation error

I am using new android studio for my project.
i am getting compilation error.
i am also using two external jar file in my project.
1:-commons-net-3.2.jar
2:-commons-net-3.2-sources.jar
Cant get what goes wrong please help.
following is error message.
Gradle: FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':FtpSample:compileDebug'.
Compilation failed; see the compiler error output for details.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
EDIT : this was a workaround available up to Android-Studio 0.2.0
One thing you can do is deactivate the external build. To do so click on "compiler settings icon".
Uncheck "Use External build
And you will see the errors in the console
I found the problem with some external jar and gradle system .
if your jar file dosent compile then just open
build.gradle--> then edit following code .
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/your jar file')
}
i hope this help people with same error

Resources