Problem with Android Studio in running Flutter project - android

Can anyone tell me what's wrong with Android Studio. I cannot run flutter projects. It returns the error showed in the picture.
Android Studio version: 3.6.3
Flutter version: 1.22.1 with Dart 2.10.1
The Error showed while executing main.dart:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 41
What went wrong:
A problem occurred evaluating script.
FlutterPlugin
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
Error message from main.dart

I have faced this error before and the solution that works for me is to clean the build folder by using
flutter clean
and uninstall the app from emulator/connect to any other device

Found the solution:
I had to delete the cache file from .gradle folder and run project. And it worked.
Directory of the cache file: C:\user(username)\ .gradle

I changed the virtual device's x86 image to x86_64 and the problem was solved. Still don't understand the underlying cause, but it worked.

Related

fastutil 7.2.0 .jar cannot be created

I have installed android studio properly, gave it all it needed for flutter development, java jdk version is 11, paths are properly given, the emulator runs fine but when i try to build my app on either emulator or a physical device, I get this error:
Launching lib\main.dart on V2109 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
Where:
Build file 'D:\untitled1\android\app\build.gradle' line: 26
What went wrong:
A problem occurred evaluating project ':app'.
java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to create Jar file C:\Users\ADMIN.gradle\caches\jars-9\53ad1f30a5eec66e4e9dc584d5b89b7f\fastutil-7.2.0.jar.
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
Exception: Gradle task assembleDebug failed with exit code 1
Here is my flutter doctor response
Please help. Your help will be appreciated
I was expecting the project to run properly, as with the same flutter doctor response and same installation procedures on 2 different laptops I was able to run properly. I have tried reinstalling android studio thrice but of no help. tried everything I could related to java (installed different versions, updating paths).

Unable to create bundle in flutter

I am building a flutter project using Gradle. When I ran
flutter build appbundle
I got the error as shown below
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':image_gallery_saver:compileReleaseKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet
Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by Gradle. Make
sure Gradle is running on a JDK, not JRE.
* 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 24s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done
25.7s Gradle task bundleRelease failed with exit code 1
Please help me regarding this issue.
Thanks in advance!
Make sure Gradle is running on a JDK, not JRE
You are running gradle on a JRE instead of a JDK, install JDK 16 or below (17 is not supported yet), append its bin directory to the PATH variable and remove the one of the JRE.

I get this error when trying to run an app via flutter on vscode

I just finished setting flutter up in VS Code, I created an android emulator and it runs fine, but when i try to launch the demo app of flutter i get this error:
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Parameter format not correct -
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files\Java\jre1.8.0_291' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
* 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 4s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
What's the problem?
Install Android Studio, it is a must if you are new, you can always use VSCODE for development but Android studio needs to be there.
Best way is uninstall vscode, install android studio, install flutter and dart plugin in android studio, then install vscode, it will work.
Also try running
flutter doctor
What does it say?

flutter run returns error failed to create jar file

I'm trying to run 'flutter run' but it returns the following error. Any idea on whats causing this to happen?
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling
software rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 in debug mode...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Failed to create Jar file C:\Users\User.gradle\caches\jars-8\54252edd90659a19228cc919a3e977c6\kotlin-compiler-embeddable-1.3.50.jar.
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 5s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 6.3s
Exception: Gradle task assembleDebug failed with exit code 1
In my case, I freshly installed Flutter to my machine. I have created a new project, tried the compile it. In this first compilation process, it was taking long, so I have killed the compilation process with CTRL+C so that I can pass --verbose flag to flutter run to see what's taking so long. Then I got this error on the next verbose compilation.
Looking at the logs, I've managed to figure out that "Maybe, I have terminated the first compilation process while it was installing Gradle to my local machine, so it kinda screwed it up while it was doing its job.".
I have removed my ~/.gradle directory and rerun again and it worked flawlessly.
The problem here is, this folder
C:\Users\User.gradle\caches\jars-8\54252edd90659a19228cc919a3e977c6
Is currently empty. It should have kotlin-compiler-embeddable-1.3.50.jar. How I fixed this problem, I have searched on Google for kotlin-compiler-embeddable-1.3.50.jar. From Google, I have downloaded this kotlin-compiler-embeddable-1.3.50.jar. After downloading I have pasted that particular jar file here -> C:\Users\User.gradle\caches\jars-8\54252edd90659a19228cc919a3e977c6.
Now I am not getting this error anymore.
You can download kotlin-compiler-embeddable-1.3.50.jar from here :
https://jar-download.com/artifacts/org.jetbrains.kotlin/kotlin-compiler-client-embeddable/1.3.50/source-code

Run a Flutter Project with Android Studio is not possible anymore

I startet my Flutter project via Android Studio for a while and i had no problem to code and to run this project from e AVD oder a physiical Device (via USB). One week ago, i had a problem because of JAVA_HOME. I could solved this problem but its still not possible to run this problem. Bow i have this message when i try to run my project:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
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
Finished with error: Gradle task assembleDebug failed with exit code 1
What can i do?
1- project fence
2- select Android / gradle / wrapper / gradle-wrapper.properties
3- change the distributionUrl line
to https \: //services.gradle.org/distributions/gradle-6.3-all.zip
That solves your problem?
Reference image
They asked the same thing here
https://stackoverflow.com/questions/35000729/android-studio-could-not-initialize-class-org-codehaus-groovy-runtime-invokerhel

Categories

Resources