Flutter and Android Studio installation broken by recent update - android

I recently updated my Flutter installation because there's was a little notification in Android Studio. Now it's broken.
Whenever I try to run my app I get this error message;
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
When I check the versions of everything I get;
Flutter 2.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 02c026b03c (2 weeks ago) • 2021-05-27 12:24:44 -0700
Engine • revision 0fdb562ac8
Tools • Dart 2.13.1
Gradle is version 7.0.2 and the flutter, dart and gradle plugins all seem to be installed and updated in Android Studio.
I have Java 16.0.1 and JAVA_HOME seems to be set correctly in the system variables. And the path to Flutter seems to be correct as well.
Inside the directory for my app, I also have android\build.gradle and android\settings.gradle
What am I missing?

Unfortunately, the solution to this was to completely remove any trace of flutter, android studio, java and gradle, and to reinstall everything from scratch. Just be aware that if you do this you may run into to problems with your code if you copy / paste it from your old app.

Related

Device not applicable for the "main.dart" configuration ,

I use Android Studio as my IDE in coding Flutter. I was able to create 2 projects before this and it worked absolutely fine. I had to clone a repo from Github. The IDE said to get config. I did that then this happened.
I already installed sdk .
My android devices android version is 7.0
Flutter Doctor result:
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18363.720], locale en-US)
• Flutter version 1.12.13+hotfix.8 at C:\src\flutter\flutter
• Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[!] Android Studio
• Android Studio at C:\Program
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
X android-studio-dir = C:\Program
X Android Studio not found at C:\Program
• Try updating or re-installing Android Studio.
• Consider removing your android-studio-dir setting by running:
flutter config --android-studio-dir=
[!] VS Code
• VS Code at C:\Users\Tamim Mostafa\AppData\Local\Programs\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 4 categories.
I also tried changing the directory an using folder with no white space. I moved the Sdk folder to D:\Android\Sdk. flutter doctor -v:
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18363.720], locale en-US)
• Flutter version 1.12.13+hotfix.8 at C:\src\flutter\flutter
• Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
[X] Android toolchain - develop for Android devices
X ANDROID_HOME = D:\Android\Sdk
but Android SDK not found at this location.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[!] Android Studio
• Android Studio at C:\Program
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
X android-studio-dir = C:\Program
X Android Studio not found at C:\Program
• Try updating or re-installing Android Studio.
• Consider removing your android-studio-dir setting by running:
flutter config --android-studio-dir=
[!] VS Code
• VS Code at C:\Users\Tamim Mostafa\AppData\Local\Programs\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 4 categories.
I've had the same issue and what worked for me is to re-import the project.
File > Close Project, go to the project's directory and delete the .idea folder.
Then File > Open... and re-open the project.
Open Project Structure, you can set the project's SDK with what you have.
After this, I was able to run main.dart with the emulator.
It solved my problem:
Make sure Flutter plugin is installed in android studio, you can install the plugin from file > setting > plugin
choose flutter SDK path from File > setting> Language & Framework > flutter.
It took me a while to find Project that the others are seeing, it's probably due to the updated version of Android Studio. I found it on External Libraries on the left panel and under it, right click on the Android API (NN) Platform > Open Library Settings > Project under Project Settings and on the right panel, change the Android API. I had <No SDK>, see screenshot.
This seems to be the problem:
[X] Android toolchain - develop for Android devices
-> ANDROID_HOME = D:\Android\Sdk but Android SDK not found at this location.
Since you said that you added the Android SDK to your D directory, you could just add D:\Android\sdk\tools and D:\Android\sdk\platform-tools to your PATH environment variable. This is how you can add it to your Path enviroment variable: https://docs.telerik.com/teststudio/features/test-runners/add-path-environment-variables
It seems like this problem may have a lot of different symptoms, but for me to be able to run my flutter app in my android device, I had to set the android SDK in the Project Structure modal.
You can open the Project Structure modal by right clicking on the project root folder (in the file tree) > Module Settings > Project and set the Project SDK:
Mine is like this:
If somehow the Project tab is disabled or in a weird state, I recommend you to close android studio, delete the project .iml file and the .idea folder, reopen the project in AS (open existing project) and set the android SDK in the project structure like I've described above. At least this is what I did and it fixed for me, so I hope this answer help someone.
Go to Tools > SDK Manager > SDK Tools and check Google USB Driver. Restart Android Studio.
All this worked for me, might be helpful to someone.
All you need is to run Android Studio as Administrator.
Thats warning said "Android SDK location should not contain whitespace". There is a whitespace character in Tamim Mustofa.
You can move sdk folder to new folder like D:\Android\Sdk, where there is no space or other whitespace character in the path.
Change Android Sdk Location address in Android Studio.
and add variabel ANDROID_HOME in your Environment Variable: System Variable. with D:\Android\Sdk as variable value
Some SDK versions of Flutter may cause the problem of not being able to find the device or simulator.You can switch the SDK version to the stable version.
I had a same problem on my Mac with the Flutter version 1.17.4, and it worked after I went back the version to 1.17.3.
Version rollback step:
1.Open the Flutter GitHub repository.
2.Click 'master' button to open the switch menu. And the click 'Tags' item.
3.Search the stable version tag(e.g. 1.17.3).
4.Open the tag and click the commits.
5.Copy the top commit id.
6.Run the command 'git reset --hard $(commit id)' in the Flutter directory.
7.Restart the Android Studio.
File > Invalide caches/restart, work for me
If you are using macOS and the other answers did not work, try this
flutter config --enable-macos-desktop
For me, going to device manager in android studio and running the emulator, fixed it. Thus the emulator has to be running before you can select it to run the application on, which makes sense I guess...
In my case there was no package attribute in the android/app/src/main/AndroidManifest.xml file for the manifest tag. Adding it solved the problem:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package.name">
OR
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="#applicationId">
type to terminal this below
flutter config --android-sdk ANDROID_SDK_PATH
Reading this page helped: by the time I reached the end of this page Android Studio had fully recognised my connected mobile phone (with developer mode enabled) and it was not longer greyed out in the Devices list.
All you need is Updating the android SDK then restart the IDE.
That's it.
This kind of problem I was facing so When I was done with Invalid caches/ restart then it automatically detect the main. dart and works fine.
Just give it a try with Invalid Caches/ Restart.
Check your Dart SDK and Flutter SDK path setup in the Environment variable setup and inside the setting of the android studio as well.
If it is ok then Do Invalid Caches/ Restart the project and Check.
It might be helped. !!!

Error ":app:transformClassesWithDexBuilderForDebug" when upgrade to new version of flutter

I upgrade flutter from v1.91. hotfix 6 by using flutter upgrade --force.
Then i build an example "layers" - flutter run, it shows this message, while if i switch to 1.91, everything built ok
flutter run --stacktrace gives this error
Could not find an option named "stacktrace".
flutter doctor -v
G:\new\new_exam>flutter doctor -v [√] Flutter (Channel stable,
v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.535],
locale en-US) • Flutter version 1.12.13+hotfix.5 at G:\Flutter\flutter
• Framework revision 27321eb (12 days ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6 • Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK
version 29.0.2) • Android SDK at G:\Flutter\android • Android NDK
location not configured (optional; useful for native profiling
support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME =
G:\Flutter\android • ANDROID_SDK_ROOT = G:\Flutter\android\sdk • Java
binary at: G:\flutter\openjdk\bin\java • Java version OpenJDK Runtime
Environment (build 1.8.0_232-b09) • All Android licenses accepted.
[!] Android Studio (not installed) • Android Studio not found;
download from https://developer.android.com/studio/index.html (or
visit https://flutter.dev/setup/#android-setup for detailed
instructions).
[!] IntelliJ IDEA Community Edition (version 2019.3) • IntelliJ at
C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.1 X
Flutter plugin not installed; this adds Flutter specific
functionality. X Dart plugin not installed; this adds Dart specific
functionality. • For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[!] Connected device ! No devices available
! Doctor found issues in 3 categories.
1: https://i.stack.imgur.com/B4DTX.png
I feel the solution is pretty straight forward. Usually, it's always a best practice to use Android Studio when working with Flutter and Dart. Reasons are there are some dependencies that would require you to use Android Studio to have it work well for you, especially when you're just starting to work with Flutter and Dart.
Flutter Doctor is pretty precise as to the issues you're experiencing.
After downloading Android Studio, do the following;
Navigate to your Preferences or Android Studio Settings on PC, then select, Plugins, ensure the following plugins are installed.
Android APK Support
Android NDK Support
Dart
Flutter
EditorConfig
App Links Assistant
Google Services
Gradle
Properties Support
Java Bytecode Decompiler
Java Stream Debugger
Task Management
YAML
Among others which would be automatically installed by Android Studio for you, this should take that error away and you should be fine.
Then, before you probably run your App, if you see the get dependencies at the Top of your Android Studio, click the get dependencies so that Android studio can get the latest dependencies to run your App without issues.
Ensure you run a cold restart after each time you add a new dependency to your pubspec.yaml file.

Android Studio - Flutter plugin not installed; this adds Flutter specific functionality

Considering that I had followed all this steps https://flutter.dev/docs/get-started/install/linux in my Ubuntu 18.04LTS, why this following problem continues to appear:
$ flutter doctor -v
[✓] Flutter (Channel stable, v1.7.8+hotfix.2, on Linux, locale en_US.UTF-8)
• Flutter version 1.7.8+hotfix.2 at /opt/flutter
• Framework revision 2e540931f7 (2 weeks ago), 2019-07-02 09:31:07 -0700
• Engine revision b1cb0d9e9b
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /home/rodrigo/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /home/rodrigo/Android/Sdk
• Java binary at: /usr/share/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b16-5323222)
• All Android licenses accepted.
[✓] Android Studio (version 3.4)
• Android Studio at /usr/share/android-studio
• Flutter plugin version 37.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b16-5323222)
[!] Android Studio
• Android Studio at /opt/android-studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b16-5323222)
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API
29) (emulator)
! Doctor found issues in 1 category.
Different from another similar questions here in StackOverflow, before I've installed flutter plugin the "[✓] Android Studio (version 3.4)" was equal to "[!] Android Studio", with same error messages. After I've installed flutter plugin (and dart), only "[!] Android Studio" still displaying the error.
Does someone know why? I've made many searches in my files, I have only one Android Studio installed. Why displays two? What "[!] Android Studio" refer to? Does command "$ flutter doctor" have a problem?
This post is for those who have gotten the plug-ins installed but still receive the warning.
Note: The Flutter team has created an issue for the inability of doctor to detect installed plug-ins. It's a know issue and they are looking to deprecate this detection feature of doctor:
https://github.com/flutter/flutter/issues/61246
My flutter and dart plug-ins are correctly installed but I still get the warning.
[!] Android Studio (version 4.0)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
In my case ignoring the warning worked fine.
I tried re-installing plug-ins several times but that did not remove the warning from flutter doctor.
However, everything works fine. I can successfully create and run apps created from
the command line with flutter create
from Android Studio with File->New->New Flutter Project
I'm on Ubuntu 20.04 LTS and Android Studio 4.0.1 (installed through JetBrains toolbox)
I installed flutter via the snap store:
sudo snap install flutter --classic
sudo snap install flutter-gallery
flutter channel dev
flutter upgrade
flutter config --enable-linux-desktop
# wanted to try web, apparently requires beta channel
flutter channel beta
flutter channel upgrade
flutter config --enable-web
FYI, it took me a while to understand where the Flutter SDK was located. It is here: /home/(username)/snap/flutter/common/flutter
Plugins installed correctly, but still get warning:
This can be solved in simple steps:
Step 1: Open Android Studio
Step 2: Open Android Studio Preferences
Step 3: Go-to Plugins tab
Step 4: Click on MarketPlace tab
Step 5: Search for flutter in search box
You will see a list of plugins related to flutter. Click on the first one and check which version it is. Currently, the latest version is 37.1.1.
Step 6: Click on install. (It may ask you to install dart plugin also. Hit yes and android studio will install dart and flutter for you)
Ready to rock !
I recently encountered this problem, I first tried to update the flutter and dart plugin from the android studio market place, but that did not work
Finally, I run the following command and it worked like a charm
ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1
Note: I'm on Mac OS running android studio 4.1

Flutter build_runner package will not update

I have a weird Flutter 'get packages' issue:
Setup:
The project I am working on, up to this point has been using a rather basic, home-brewed model system. We have some functions to consume data, and without much validation, assign it to object keys inside immutable objects. It is rather crude, and we want to standardize on something more widely used, and hopefully robust.
Some recent research has pointed us to the built_value package, because it seems to offer not only a more standard way of defining models, but also can cut down on boiler plate that we have been writing over and over. We found some instructions online for adding this to our project. Essentially, we have to add two dependencies and two dev_dependencies. Here is what the basis pubspec.yaml looks like:
name: projectname
description: my project rocks!
version: 1.0.0
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: 'flutter'
...
built_collection: '^4.1.0'
built_value: '^6.3.0'
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: '^1.2.1'
built_value_generator: '^6.3.0'
And this is what flutter doctor says:
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version
10.0.17134.523], locale en-US)
• Flutter version 1.0.0 at c:\flutter\flutter
• Framework revision 5391447fae (9 weeks ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at C:\Users\MYUSER\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 32.0.1
• Dart plugin version 182.5124
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[√] Connected device (1 available)
• MY PHONE
• No issues found!
Issue:
On the surface, it looks like everything is ok. But then, in Intellij (where all this above was copied from), I use the flutter 'Packages get' command (even using the commandline version inside the project dir, I get the same results):
Running "flutter packages get" in projectname...
The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.
Because build_runner >=1.2.0 depends on build_daemon >=0.2.0 which requires SDK version >=2.1.0 <3.0.0, build_runner >=1.2.0 is forbidden.
So, because projectnamedepends on build_runner ^1.2.1, version solving failed.
pub get failed (1)
Process finished with exit code 1
Now, the interesting part is that I have it set to use the 'stable' branch of flutter, which is currently at version "2.1.0-dev.9.4.flutter-f9ebf21297" which flutter doctor is registering as version "2.1.0". However, when trying to do the packages get command flutter seems to think that "2.1.0-dev.9.4.flutter-f9ebf21297" is not ">=2.1.0 <3.0.0".
All of the versions for the packages are the latest versions, according to their git repos. Flutter is up to date with the latest stable branch (I have redone this twice now to make sure). Flutter doctor command seems to think that everything is correct... and yet I cannot complete the 'packages get' command because build_daemon (a dep of build_runner) requires ">=2.1.0 <3.0.0" and the flutter script is not recognizing that version "2.1.0-dev.9.4.flutter-f9ebf21297" >= "2.1.0", which by it's own admission in flutter doctor, it is.
Request:
I have been racking my brain for solutions. I have tried switching to the master branch for flutter manually, but when I run it from Intellij, it switches right back to stable. I have tried a complete reinstall of flutter, and that did not help. I have been fighting with these things for a while now, thinking that I am doing something wrong, and have not made any headway. I have read every piece of documentation I can find on the topic, and nothing seems to indicate that anyone other than me is having this issue. So I am at a loss.
I am reaching out to the community, in an attempt to get this working. I feel like I am missing something glaringly obvious here, and I think having your eyes look at this in addition to mine, will help solve the issue. What do you suggest I do to resolve this issue?
Thanks in advance,
Loushou
Based on the release notes, this should be fixed on the later versions. The current version is build_runner: ^2.1.5 and this supports the null safety feature.
I suggest for this kind of situation to always check if the latest version of a plugin is available and use it. Most of the time the bugs/errors from the previous versions was being addressed on the succeeding versions.

Flutter not detecting Android SDK

I've been trying to get flutter to detect the Android SDK.
flutter doctor
returns
PS I:\Projects\Flutter\fluttertest\flutterproject> flutter doctor -v
[√] Flutter (Channel beta, v0.1.5, on Microsoft Windows [Version
10.0.16299.248], locale en-US)
• Flutter version 0.1.5 at I:\Source\flutter
• Framework revision 3ea4d06340 (7 days ago), 2018-02-22 11:12:39 -0800
• Engine revision ead227f118
• Dart version 2.0.0-dev.28.0.flutter-0b4f01f759
[!] Android toolchain - develop for Android devices
• Android SDK at C:\NVPACK\android-sdk-windows
• Android NDK location not configured (optional; useful for native profiling support)
• ANDROID_HOME = C:\NVPACK\android-sdk-windows
X Android SDK is missing command line tools; download from "link to google"
• Try re-installing or updating your Android SDK,
visit https://flutter.io/setup/#android-setup for detailed instructions.
[√] Android Studio (version 3.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[√] VS Code (version 1.20.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Dart Code extension version 2.9.2
[√] Connected devices (1 available)
• Nexus 6P • 8XV7N16A04000597 • android-arm64 • Android 8.1.0 (API 27)
! Doctor found issues in 1 category.
I've tried downloading the SDK Tools Package and even Installed Android Studio
and added it to PATH, but was unable to resolve the issue.
The current Android installation sits in a directory called C:\NVPACK, and although I do remember fiddling with it, I don't remember which program installed it. I'm considering removing it. Any help would be greatly appreciated.
Flutter provide command to update our Android SDK path:
Use flutter config --android-sdk <path-to-your-android-sdk-path>
Or just add a variable ANDROID_HOME with your sdk location in user variables
It turns out that I had NVIDIA CodeWorks installed. I believe it was part of my VS2017 installation options. I've removed it and modified my ANDROID_HOME Environment Variable and removed all of the variables associated with the NVPACK folder. (thanks to everyone (1) who helped me offsite!)
You have to set ANDROID_HOME variable to SDK.
create a new variable by the name and set it to the installation directory.
make sure SDK is not below 2 subfolders from c drive or any windows root drive.
Open Android Studio.
Click on Tools go to Sdk manager.
Then click on SDK tools.
Unchecked Hide Obsolete Packages then Check Android SDK Tools.
Then Tools will be install after that you can set the path and check the connectivity.
Your problem will resolve.
Go into C:\Users\asus\AppData\Local\Android\sdk, double cliclk on sdk mannager.exe and update all packages.
It will take around 10 minutes to update which also depends on your internet speed.
You need to install the command-line tools inside Android studio, as explained here:
Flutter doctor error - Android sdkmanager tool not found. Windows
For Mac Users use:
flutter config --android-sdk /Users/<your-user>/Library/Android/sdk
I have installed Flutter with Android Studio many times. And I found most of the installation errors were because of poor network connection. When I use fast internet service, Flutter Environment was set up within an hour without any issue.
Internet speed is very important while Flutter, Android Studio, and SDK installation.
Best,
Ahmed I.
1- Activate Command-line Tools and download it as in this picture
2- Add Android SDK path to your system environment variables.
this link would help you..

Categories

Resources