Flutter debugging fails - android

I want to run a flutter application that I wrote on Visual Studio Code on the device. However, when I do this, I always get the following error. Normally this wouldn't happen, it's just starting to happen. I'm not entirely sure what I should do.
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 '/usr/lib/jvm/oracle-java8-jre-amd64' 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
BUİLD FAILED in 45s
Exception: Gradle task assembleDebug failed with exit code 1
OS : Ubuntu
Mobile Device : Samsung J500F
Android Version : 6.0.1

You need to have installed a JDK. Depending on which version of Ubuntu you should just be able to do sudo apt install openjdk-8-jre-headless
That said, I would target a higher Java version, if I were you, maybe 11?
Either way, if you look at the path your JRE is in, it's '/usr/lib/jvm/oracle-java8-jre-amd64'
You don't want to be using the regular JRE to build/run your application. You want to build and run with openjdk. That's why your error message says,
"Make sure Gradle is running on a JDK, not JRE."

The message Execution failed for task ':app:compileDebugKotlin' and the Gradle issue indicate that your problem is not about Flutter but about Android, and more precisely about the lack of JDK (which allows to execute Java and Kotlin code).
To solve this problem, it is necessary to review the configuration of your project.
I advise you if possible to use Android Studio, an IDE recommended by Android developers and that will make things much easier with Android and Flutter.
This article from the official Android documentation and this one from JetBrains should help you solve your problem.
You can install Android Studio from snap store or zip

Related

Building a c++ application with gradle on host linux aarch64

My host is a linux aarch64 machine on Android Galaxy Tab S4 with Termux installed as my development environment.
Installed in Termux is NDK v22, Clang 12.0.2, Gradle 7.1.1, android-sdk (30.0.3) and kotlin 1.5.21.
I init'ed a new c++ application project with gradle and the default template project-files and directories were initialized.
When I try to build now the project, I got following errors:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugCpp'.
> Error while evaluating property 'compilerVersion' of task ':app:compileDebugCpp'
> No tool chain is available to build C++ for host operating system 'Linux' architecture 'aarch64':
- Tool chain 'visualCpp' (Visual Studio):
- Visual Studio is not available on this operating system.
- Tool chain 'gcc' (GNU GCC):
- Don't know how to build for host operating system 'Linux' architecture 'aarch64'.
- Tool chain 'clang' (Clang):
- Don't know how to build for host operating system 'Linux' architecture 'aarch64'.
* 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
1 actionable task: 1 executed
My use-cases will be, to build c++ libraries, later using kotlin/native and integrating as last task everything into an apk with the help of gradle/kotlin/ndk etc.
What does this error mean?
Is there really no support for linux aarch64 hosts or do I need to change some configuration settings in the build.gradle file?
I searched the gradle documents, internet and kotlin/native manual but cannot found a solution.
Thanks in advance for your help.
Is Clang found if you try to call it directly without gradle?
Please make sure that you can compile anything with Clang from command line.
Then you may need to fine tune your native tool chain for Gradle as described in https://docs.gradle.org/current/userguide/native_software.html#native_binaries:tool_chain

How can I use Cordova without installing Android Studio?

I use an old computer for development, and my current specs doesn't meet Android Studio's System requirements.
I am a newbie, and only know some JS/HTML5. And I'm trying to enable oAuth for Firebase Auth services for Android.
I downloaded the Commandline Tools from https://developer.android.com/studio/ (far at the bottom of the page) and tried to use sdkmanager.bat, but I can't make it accept commands. I added its Path to the Environment variable "path", and then tried using Windows PowerShell. But writing any command will just make it start over again. (maybe it was something foolish of me)
Then I downloaded and installed Gradle.
After that when I write cordova requirements I get the following result:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
No android targets (SDKs) installed!
Gradle: installed C:\Users\Sparsha\Desktop\gradle-6.5-all\gradle-6.5\bin\gradle
Some of requirements check failed
I am not sure how Android SDK installed became true, but Android target is not installed (Don't know how to install).
Also, using cordova build gives me the following results:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\Sparsha\Desktop\commandlinetools-win-6514223_latest (DEPRECATED)
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.5/userguide/gradle_daemon.html
Process command line: C:\Program Files\Java\jdk1.8.0_251\bin\java.exe -Xmx2048m -Dfile.encoding=windows-1252 -Duser.country=IN -Duser.
language=en -Duser.variant -cp C:\Users\Sparsha\Desktop\gradle-6.5-all\gradle-6.5\lib\gradle-launcher-6.5.jar org.gradle.launcher.daem
on.bootstrap.GradleDaemon 6.5
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
* 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
C:\Users\Sparsha\Desktop\gradle-6.5-all\gradle-6.5\bin\gradle: Command failed with exit code 1
Thanks...
Whatever you downloaded from that URL is not needed. That is probably the SDK for Android Studio.
To setup your Cordova tools to develop Cordova apps with either Visual Studio or your favorite text editor like Notepad++, follow this detailed guide which I created earlier.
Let me know if you have any questions.

Flutter VSCode : Debug error:Could not create service of type FileHasher using BuildSessionServices.createFileHasher()

Trying to start programming Dart in Flutter. I wanted to work with VSCode instead of Android Studio, but when debug session starts I get the following problems.
I tried everything here in this link such as deleting the caches, deleting lock file, kill PID Task in cmd, but nothing works.
However, I'm able to run the test app in Android Studio, but still, I wanted to learn via VSCode. It will be great if you can share any suggestion that might help :)
Thanks!
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type FileHasher using BuildSessionServices.createFileHasher().
> Unexpected lock protocol found in lock file. Expected 3, found 0.
* 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
Flutter SDK: windows 1.17.1 (from the website)
Android Studio: 3.6.3
Able to solve my own problem. Apparently, when I first sync the demo app in VSCode, it started to download package from gradle 5.62, whereas 6.4 available in my machine. Which then I changed the setting and distributionUrl thingy to that version 6.4 . And when I started to run it, that error stated in the question surfaced.
What I did was:
Go to project level .gradle file (app> android> .gradle)
Delete the file of gralde of the other version
Go to the gradle folder of the 6.4 version, delete the lock file in caches/filehashes
restart
In android/app/build.gradle
Try changing minSdkVersion to 21
I had same issue this worked
For Windows machine:
Open Task Manager(Ctrl-Alt-Delete and check Process)
-> Close All instances of Android Studio/VS Code (End Task)
-> Close Emulator (if Running)
-> Then close OpenJDK Platform Binary
it will work now

Why can't I run my Cordova Project in Android?

I am trying to run my Cordova Project in a Android platform on a Mac.
I downloaded Android Studio.
However, whenever I try to run the following command line in terminal
cordova run android
it ends in the following error:
BUILD FAILED
Total time: 1.391 secs
Error: /Users/karel/Cordova Projects/demo/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 25].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Am I missing something?
It works for
cordova run ios
cordova run osx
cordova run browser
How can I accept these terms the message is talking about? I recall accepting to certain terms, at least, when downloading Android Studio.
I am wondering whether I have to install Android SDK separately from Android Studio or something. (I have no experience with Android).
Thanks for your time. Your help would mean a lot.

Android studio build failed exception while build with different emulator?

Error:FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:clean'.
Unable to delete directory: /media/user/7EA01F5FA01F1CE9/GitWorkSpace/Myapplication/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/jars
Try: Run with --stacktrace option to get the stack trace. Run with
--debug option to get more log output.
How to fix this issue in android studio? Whenever i'm trying to take build in different emulator i have to delete manually build folder inside the app then only i can successfully build the application.
How to fix this issue permanently?
I have faced the same problem, my android studio version 2.0 and OS Ubuntu. So, far I didn't found any permanent solution and this problem is current IDE version. You can also check details from here:
https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=206219
So, you can use lower IDE version temporarily (I know this is not a good solution)

Categories

Resources