building flutter demo app failure with andriod emulator - android

device : Macbook pro catalina and all softwares are up to date .
I did all the correct steps for setting up flutter in android studio , installing the recommended emulator , every thing is ok but building flutter demo app didnt work in emulator (it was worked perfectly in IOS simulator) and showed this error :
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:desugarDebugFileDependencies'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
/Users/heshamayman/Library/Android/sdk/build-tools/28.0.3/core-lambda-stubs.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 39s
Finished with error: Gradle task assembleDebug failed with exit code 1

The error you are facing might be due to partial installation of SDK on your device.
Here, how you may be able to fix it.
First Navigate to /Users/heshamayman/Library/Android/sdk/build-tools/ using finder.(CAN BE HIDDEN IN CASE PRESS [command+shift+.] TO SHOW HIDDEN FILE IN FINDER)
Then delete the folder 28.0.3
After DELETING:
In Android Studio:
GO TO TOOLS -> SDK MANAGER
SELECT SDK Tools -> Show Package Details -> select 28.0.3 (assuming it got deleted on first place).
This worked for me. Hope this will work for you also. :D

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).

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

Flutter not running on Android Device

I just created a new project using command palletes in vsCode. then i start android simulator and then flutter run. it's running perfectly on ios not on android .
this debug console response
Launching lib/main.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAidl'.
java.lang.IllegalStateException: aidl is missing from '/Users/sachin/Library/Android/sdk/build-tools/26.0.2/aidl'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Gradle build failed: 1
Exited (sigterm)
Just now I encounter the same problem. It happened because after doing "flutter run" there's still some file that needs to be downloaded, the build tools, but didn't get downloaded correctly, because I stopped it in the middle, since I thought the process was stuck.
So, these are the steps that solve the problem:
open terminal
change directory to /Users/[USERNAME]/Library/Android/sdk/build-tools/, in your case, type cd /Users/sachin/Library/Android/sdk/build-tools/
remove the folder that causes the error, in your case the 26.0.2 folder, so in your terminal type rm -r 26.0.2 to remove it.
go back to your code, make sure the android simulator is detected, and re run the project
now, wait patiently, it may takes sometime (depends on internet connection), but it's downloading the build tools, you can watch this in the finder by typing open .
make sure that in the 26.0.2 folder there's aidl file added when the process is finished.
it should be working, if not, just rebuild/re-run your code one more time. Done!

Categories

Resources