(M1 Mac) Android Studio Doesn't Detect Android Emulator - flutter

I just downloaded android emulator through android studio. Didn't use the GitHub repo to download dmg file. Then I started the S level API android emulator from and manager. Android emulator boots but android studio doesn't detect and doesn't run app on it.
What could be the problem?
Reproduced:
Remove *.lock files in avd folder (Didn't work)
flutter doctor -v
[✓] Flutter (Channel stable, 2.2.1, on macOS 11.4 20F71 darwin-arm, locale tr-TR)
• Flutter version 2.2.1 at /Users/alperenbaskaya/Desktop/flutter
• Framework revision 02c026b03c (2 weeks ago), 2021-05-27 12:24:44 -0700
• Engine revision 0fdb562ac8
• Dart version 2.13.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/alperenbaskaya/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.10.1
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.

1)Try enabling USB Debugging in the Android emulator itself, as you would do on a real device. Settings-> Developer options-> enable USB Debugging.
2)Probably the project you are running is not compatible (API version/Hardware requirements) with the emulator settings. Check-in your build.gradle file if the target SDK and minimum SDK version are lower or equal to the SDK version of your Emulator.
You should also uncheck Tools > Android > Enable ADB Integration
If your case is different then restart your Android Studio and run the emulator again.
For more info:
Android studio: emulator is running but not showing up in Run App "choose a running device"
Android Studio does not detect the emulator

I went to the AVD Manager and in the options for the particular emulator I selected "Cold Boot Now" and it resolved my issue.

Related

flutter iOS Simulator - Connecting to the VM Service is taking longer than expected

I'm getting this error when I try to run my application on the iOS simulator:
Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
Running Xcode build...
└─Compiling, linking and signing... 9,2s
Xcode build done. 27,9s
Connecting to the VM Service is taking longer than expected...
Still attempting to connect to the VM Service...
If you do NOT see the Flutter application running, it might have crashed. The device logs (e.g. from adb or XCode) might have more details.
If you do see the Flutter application running on the device, try re-running with --host-vmservice-port to use a specific port known to be available.
At the end of the Xcode build done. 27,9s print in the terminal, the App opens in the iOS simulator for a few milliseconds, but is instantly closed, and a crash screen from Xcode is opened.
Here is my flutter doctor -v:
[✓] Flutter (Channel master, 3.8.0-9.0.pre.18, on macOS 13.2 22D49 darwin-arm64, locale pt-BR)
• Flutter version 3.8.0-9.0.pre.18 on channel master at /Users/rafael/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f945ad99c3 (55 minutes ago), 2023-02-10 00:05:44 +0100
• Engine revision 40e17fb524
• Dart version 3.0.0 (build 3.0.0-218.0.dev)
• DevTools version 2.21.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc2)
• Android SDK at /Users/rafael/Library/Android/sdk
• Platform android-33, build-tools 33.0.0-rc2
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.75.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (3 available)
• iPhone 14 Pro Max (mobile) • 49BFE69F-8CDD-4726-A6A4-60AC1E87E6E9 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.2 22D49 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I solved the problem by removing a package that I had in the application that has the pub google_mobile_ads in its .yaml, and as I am not implementing Ads in this App I did not configure the necessary items in AndroidManifest.xml and Info.plist.

Unable to find any JVMs matching version "1.8"

Im new to flutter. Im running on macos catalina(10.15.7 (19H15)). I installed Flutter(2.2.3)
I download java 16 and installed it. And also i set the path.
java version "16.0.2" 2021-07-20
Java(TM) SE Runtime Environment (build 16.0.2+7-67)
Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)
thilinaabhisheka#Thilinas-MacBook-Air ~ % /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
16.0.2, x86_64: "Java SE 16.0.2" /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
Im using Android studio 2020.3.1. when im run flutter doctor I got this error
Unable to find any JVMs matching version "1.8".
Unable to find any JVMs matching version "1.8".
[✓] Flutter (Channel stable, 2.2.3, on Mac OS X 10.15.7 19H15 darwin-x64, locale en-GB)
• Flutter version 2.2.3 at /Users/thilinaabhisheka/Developer/Flutter
• Framework revision f4abaa0735 (8 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
⣟Unable to find any JVMs matching version "1.8". [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/thilinaabhisheka/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /usr/bin/java
• Java version Java(TM) SE Runtime Environment (build 16.0.2+7-67)
• All Android licenses accepted.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[✓] Connected device (2 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159
! Doctor found issues in 2 categories.
Install homebrew
now try it brew install --cask homebrew/cask-versions/adoptopenjdk8
if you have used an android studio then set from the project structure.

Flutter: Cant build app anymore since upgrade flutter and channel

Please help me!
The app was close to be finished and since I did run flutter upgrade to solve a bug I had to run:
flutter clean
flutter channel master
flutter upgrade
flutter run
and now its not starting anymore and the following code shows up..
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running Xcode build...
Xcode build done. 7,6s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
/Users/patrickmeyer/AndroidStudioProjects/my_fitness_challenge/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:140:55: error: 'currentRadioAccessTechnology' is deprecated: first deprecated in iOS 12.0 [-Werror,-Wdeprecated-declarations]
networkCurrentRadioAccessTechnology = networkInfo.currentRadioAccessTechnology;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
serviceCurrentRadioAccessTechnology
In module 'CoreTelephony' imported from /Users/patrickmeyer/AndroidStudioProjects/my_fitness_challenge/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/Public/GoogleDataTransport/GDTCORPlatform.h:32:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/CoreTelephony.framework/Headers/CTTelephonyNetworkInfo.h:154:61: note: 'currentRadioAccessTechnology' has been explicitly marked deprecated here
#property (nonatomic, readonly, retain, nullable) NSString* currentRadioAccessTechnology API_DEPRECATED_WITH_REPLACEMENT("serviceCurrentRadioAccessTechnology", ios(7.0, 12.0)) API_UNAVAILABLE(macos);
^
1 error generated.
PromisesObjC-crewhghtjvlepwbqltmbxkeqlsao
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.
My flutter doctor looks good...
[✓] Flutter (Channel master, 1.26.0-2.0.pre.117, on Mac OS X 10.15.7 19H114
darwin-x64, locale de-DE)
• Flutter version 1.26.0-2.0.pre.117 at
/Users/patrickmeyer/Developer/flutter
• Framework revision 15c009b805 (17 hours ago), 2020-12-22 20:09:03 -0500
• Engine revision b7cd3f8e70
• Dart version 2.12.0 (build 2.12.0-173.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/patrickmeyer/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
[✓] Connected device (2 available)
• iPhone 12 Pro Max (mobile) • 11ACA273-A0C3-405D-993A-A9AF9057887C • ios
• com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
• Chrome (web) • chrome •
web-javascript • Google Chrome 87.0.4280.88
• No issues found!
This could be because of compatible issues between flutter and Xcode version. Switch to the previous version and see if the error is there. Try other versions of flutter manually, using flutter version .
You can also run the program from Xcode, and try opening the emulator from there.
You can indeed use
flutter create .
to "repair" the current project to a limited degree.
If the ios/ or android/ folders are missing, they are created.
You can use this to switch native language Java/Kotlin, ObjC/Swift or to get the generated files updated to match newer Flutter versions by deleting the directories and running
flutter create . [options]
You need to re-apply previously made manual changes yourself though.

Exception: [!] Your app is using an unsupported Gradle project

I am trying to run my existing flutter application and I am getting this exception. How can I solve this issue?
Exception: [!] Your app is using an unsupported Gradle project. To fix this problem, create a new project by running flutter create -t app <app-directory> and then move the dart code, assets and pubspec.yaml to the new project.
Here are my Flutter doctor results:
[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.4 19E287, locale en-EE)
• Flutter version 1.17.1 at /Users/varsik/Documents/flutterConfigurationFiles/flutter
• Framework revision f7a6a7906b (2 weeks ago), 2020-05-12 18:39:00 -0700
• Engine revision 6bc433c6b6
• Dart version 2.8.2
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/varsik/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.2.1, Build version 11B500
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.8052
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (1 available)
• Pixel 3 XL • 8B8Y0VETV • android-arm64 • Android 10 (API 29)
• No issues found!
Maybe you removed a line from the
project/android/app/build.grade
Try adding this Piece of Code
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
after the line
apply plugin: 'com.android.application'
I resolve this issue by syncing project with gradle files.In android studio from menu open File option and click option sync project with gradle files.
Could you check this solution The project is using an unsupported version of Gradle
If you have the backup of your project than go to
project/android/app/build.grade
copy all the code and paste it to your project app/build.grade file.
Clean Project
Now Enjoy. Your error will not appear.
Thankyou.
For everyone landing here after making changes to the gradle for firebase or smth, it might seem stupid but check that the autoformat(if you have it enabled) didn't make funny things like putting spaces between "->" or "+=" turning them into "- >" or "+ ="

Flutter SDK is not authorized by AVD

I'm running Android studio as an administrator in Windows 10. The AVD is a Nexus 5X API 28. I'm trying to run the flutter demo, but the device drop-box still shows "no devices", it only has the "Open Android Emulator" option, which I clicked to start the AVD:
The output of
flutter doctor -v
is:
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17134.407], locale en-US)
• Flutter version 1.0.0 at C:\Users\User\flutter_windows_v1.0.0-stable\flutter
• Framework revision 5391447fae (10 days 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\User\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-1136-b06)
• All Android licenses accepted.
[√] Android Studio (version 3.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 31.1.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[!] Connected device
• Device emulator-5554 is not authorized.
You might need to check your device for an authorization dialog.
! Doctor found issues in 1 category.
Unlike in a real phone connected via USB, here there is no authorization dialog when I start the AVD. How can I authorize the phone?
This simple solution worked: Wipe data and Cold Boot.
Didn't work:
Note that in the Terminal of the Android studio, adb is not recognized (following flutter installation instructions). You can add the android SDK location path to the PATH environmental variable just to be able to run adb, but this won't give you more information than flutter doctor -v. The android SDK path should be already in Tools|SDK Manager, which is in my case "C:\Users\User\AppData\Local\Android\Sdk", nothing to do with "android-sdk-windows". Killing and restarting adb didn't work.
Logcat shows the message "Please configure Android SDK" (click on "configure", opens "Project Structure" window). The paths to SDK and default JDK are valid. Installing NDK miscofigured something else, so I uninstalled it and left this path field empty. Under "Project", all Version and Repository fields are empty.
You should add ANDROID_HOME variable to your class_path
set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
Taken from this
After that call flutter doctor -v and flutter devices