error:Unable to locate a development device; please run 'flutter doctor' for information about installing additional components - sdk

while trying to run a simple code using bloc I weren't able to test it because of that error , and before this it takes a lot of time trying to resolving dependencies and then post this error :
Unable to locate a development device; please run 'flutter doctor' for information about installing additional components.
and after running flutter doctor the result is :
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.8.2, on Microsoft Windows [Version 10.0.17134.345], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
X Android SDK file not found: C:\Users\aya sisy\AppData\Local\Android\sdk\build-tools\28.0.3\aapt.
[√] Android Studio (version 3.1)
[√] VS Code (version 1.28.1)
[√] Connected devices (1 available)
! Doctor found issues in 1 category.

Seems like the Android Sdk is not found by Flutter.
Did you set the correct ANDROID_HOME environment variable ?
It could also be coming from the path including a space "...\Users\aya sisy\AppData\...".
Can you try to move it to another location ?

The same problem happened to me, except I'm using Ubuntu 18.04, so check the following:
The solution was to remove adb from apt package manager. so see if you accidentally installed adb for windows other than the one that come with android_sdk.
and from the logs you posted, it's clear that there is something wrong inside the android_sdk path so try to move it to other directory : for ex C:\dev\android_sdk and run the following command
flutter config --android-sdk "C:\dev\android_sdk"
Hoping that helps.

Just check whether your 'Project SDK' is set in File -> Project Structure; under the section Project Settings -> Project.
For me, it was not set by default, and setting it solved the problem.

Related

Flutter run xcode build fails but building directly with xcode succeeded

I'm new to iOS development and I ran into this problem at the very beginning:
When I tried to flutter run my hello world app I got xcodebuild failed (I took only the last lines since it's too long):
81 errors generated.
<unknown>:0: error: failed to emit precompiled header '/Users/mehec/Library/Developer/Xcode/DerivedData/Runner-cssmbpuzzkyjvpfghedbpvdhbbmr/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_2PXLF604USZTM-clang_KLU4EDN5EN1U.pch' for bridging header '/Users/mehec/Desktop/bgp/learn_flutter_0_test/ios/Runner/Runner-Bridging-Header.h'
<unknown>:0: error: generate-pch command failed with exit code 1 (use -v to see invocation)
note: Using new build system
note: Planning build
note: Constructing build description
I then tried to build and run in xcode and everything's fine.
I have tried flutter clean and flutter upgrade even creating a new project but no effect
I'm using macOS 10.14.6, IntelliJ Idea 2020.1, Flutter 1.17.5 and 1.19.0, Xcode 11.3.1
the code in main.dart:
import 'package:flutter/material.dart';
void main() {
runApp(Center(
child: Text(
"hello world",
textDirection: TextDirection.rtl,
),
));
}
flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.19.0-4.3.pre, on Mac OS X 10.14.6 18G5033, locale en-US)
[✗] Android toolchain - develop for Android devices
✗ 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/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_SDK_ROOT to that location.
You may also want to add it to your PATH environment variable.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.1.3)
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
Thanks!
I had a similar problem.
The build from Xcode.app was successful, but the build from the command line or Android Studio failed.
Finally, I reinstalled rbenv, and the problem went away.
In other Github comments, some people solved the problem with conda deactivate, so I think the problem is caused by a bug in the development environment that Xcode.app does not refer to, such as ruby or python environment.

Flutter flavor for iOS gives SharedPreference error on run

Issue faced while trying to run flavors for iOS using Build Schemas
/Labs/Workspace/Flutter/camp-flutter/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error:
'shared_preferences/SharedPreferencesPlugin.h' file not found
#import <shared_preferences/SharedPreferencesPlugin.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.36.1)
[✓] Connected device (1 available)
• No issues found!
Additional Information
We are using flavors and schemes for iOS build and using below command to run applications
flutter run --flavor abcd --target lib/main/abcd_main.dart
Uh, given that we can run build flavors via the changes from flutter 1.2 to 1.5 would not that be easier?
You use a build delegate your build config will use a new target flag that points to your new build flavor via dart file..see my medium post and several others talking about ti on medium...
BuildExtensions
The only hiccup is once in a while you have to wipe the emulator or device due to it having the old build flavor but generally it works
I just tried the debug and release build and there is some rules for this workaround:
folder to add .h file
debugging on simulator => ios/Debug-iphonesimulator
debugging on iOS => 'ios/Debug-iphoneos'
release on iOS => 'ios/Release-iphoneos'
BTW, I can build my project in all modes with many 3rd lib using this workaround.
In my opinion, this problem can be resolved in two ways. They are below.
I checked in one of my project and found SharedPreferencesPlugin.h has following code.
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Flutter/Flutter.h>
#interface FLTSharedPreferencesPlugin : NSObject <FlutterPlugin>
#end
This file is present at location :
(mysiyaram is the project name)
Now you might have two ways to solve this issue.
Plan A : You create the file manually with the code above. It doesn't contain any version specific info any way.
Plan B : Create another dummy project, add shared preferences in there. And copy the file (or folder structure) from the dummy project to your project.
Note : Please take this options as a workaround since I don't know the structural solution.

Flutter and Dart Plugins Android Studios

[✗] Android toolchain - develop for Android devices
✗ ANDROID_HOME = User/grantrienstra/Library/Android/sdk
but Android SDK not found at this location.
Is what I've been getting when I run flutter doctor -v and Youtube has not yielded any answers. Do you know how to install the Android toolchain? I have Android Studios downloaded and the Flutter and Dart plugins integrated.
By checking your path I'm assuming you're on Mac so try to add the tools and platform-tools to your PATH environment variable by running the following on the terminal:
export PATH=$PATH:~/Library/Android/sdk/tools
export PATH=$PATH:~/Library/Android/sdk/platform-tools
Then you should be good to go.

New Flutter Project wizard not showing on Android Studio 3.0.1

I installed Flutter following official document and also installed Flutter and Dart plugin on Android Studio.
But, I can't see File>New Flutter Project wizard on Android Studio 3.0.1
I run "flutter doctor" command. See the below output.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.1.5, on Mac OS X 10.13.3 17D102, locale en-TR)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
[✓] Android Studio (version 3.0)
[✓] IntelliJ IDEA Community Edition (version 2017.3.3)
[!] Connected devices
! No devices available
! Doctor found issues in 1 category.
You need check the “AndroidAPK Support” in your Plugins.
See this screenshot:
If you are sure to have both Dart and Flutter plugins correctly installed, check again your Plugins and be sure that Android APK Support is enabled.
If it isn't, enable it!
Et voilà! Now everything should be fine:
You can find the plugin menu inside the Welcome page
or, when you have a project opened, inside the Preferences menu:
Had the same problem. Check-in Android Studio if the Dart and Flutter plugins are both installed and marked with a lock symbol in Preferences --> Plugins.
Anyway, the following procedure helped me:
uninstall the Flutter plugin
restart Android Studio.
uninstall the Dart plugin
restart Android Studio again which seemed important to do
install the Dart plugin again
restart Android Studio although it is annoying
install the Flutter plugin again
and guess: restart Android Studio
After the last restart I saw the success message:
I assume we both installed both plugins without restarting after Dart.
I also faced it but soon I solved it
I simply install flutter and dart plugins and restarted Android Studio.
After restarting I noticed that there is no Wizard for creating flutter apps. But soon I realized that I have disabled some plugins ( Android Studio's default plugins ) so I enabled all plugins and restarted Android Studio again and BOOM! Now there is a wizard for Creating Flutter Apps.
Hope this helps you !
My answer will be nearly same with #VickyBOSS but I'll upload screenshots of before and after ;)
First and foremost Flutter and Dart plugins must be installed before.
After installing these plugins you can check if it is ok or not with flutter doctor
If you hadn't installed the plugins you would have this:
Android Studio
At first, I didn't see "Start a new Flutter project"
After:
I have also same problem.but what can you do in that situation is Just create the project with command line :
flutter create your_app_name
Now open android studio and open that project. Hope this works well
Yes first update all your plugins related to flutter and dart .
"AndroidAPK Support" plugin(install /enable /update).
3.This will work for all the AS , checked this on AS 3.4 also .
Thanks to the guys who answered before me .
I also ran into this issue and the steps above didn't work. What I did was check which plugins I have enabled and realized that Android APK Support and Android NDK Support was disabled in my AS. After enabling this and restarting android studio everything seems to be working correctly.
This worked for me. Install Dart and Flutter manually from Plugins:
Open Plugins (For Mac: Configure -> Plugins OR Android Studio -> Preferences -> Plugins)
Search for Dart -> Search in repositories -> Install -> Restart Android studio
Search for Flutter -> Search in repositories -> Install -> Restart Android Studio
Got the same problem, fixed it by installing dart first using the plugin manager of android studio. Then install flutter plugin.
How to set flutter wizard in Android Studio 3.0
File > Close Project
Configure > Check for Updates
You will find Flutter and Dart updates. Update and Restart. Downloading Patch.
File > New Flutter Project or Select new Flutter Project.
Hope your problem resolved.
Happy Codings!!
It was little different in my case. After upgrading to newest release of Android studio. The dart flutter and other related plugins were in incompatible mode.
You can check that by going to Android Studio=> Plugins.
I simply update those plugins and then restart the IDE and it works fine.
Just Restore your IDE settings as shown in image
File -> Manage Ide Settings -> Restore default settings
This will remove your installed plugins and ask you again to install them.
Update flutter using below command
flutter upgrade
and again create flutter application from android studio
For some reason, Flutter refused to show New Flutter Project in android studio 3.1
but when I use android studio 3.2 it works fine after installing Dart and flutter plugins.
Make sure you have flutter and dart installed, then enable Android apk support; this helped me
Uninstall Flutter and Dart plugin
Restart Android Studio
Install Flutter Plugin (it will prompt you to install Dart plugin as well. Accept it)
Restart Android Studio
Also, reminder to check whether the plugin is enabled or not. Go to Preferences -> Plugins -> Flutter/Dart. Although, it's enabled by default, you may have had to disable it at some point in the past. In that case, just enable it from Preferences -> Plugin -> Flutter/Dart if you want to.
In my case I did not have APK/NDK support Plugin, added that and it worked. Of course restart IDE couple of times.
Well go to command line and check flutter doctor , if all good give command to your project directory
flutter create appname
and import this to androidstudio , this will generate necessary plugins.
I've got the same problem and finally sorted out. It's usually caused by your upgrade of Android Studio from 2.x to 3.x at the same time.
In short, it's because Flutter is not correctly configurated, but behind the scene there might be different reasons, so the universal solution is to run flutter doctor -v to diagnose and see what's missing.
[First make sure you've already followed the setup steps in Flutter's official documentation and have your Android SDK updated.]
In my own case, a couple of things to fix:
Update the JAVA_HOME path in .bash_profile. Because I have 2 Java versions installed and so I updated it to use the same as Android Studio does. This is critical as flutter doctor relies on Java to check some of your configurations.
Some Android licenses not accepted - follow flutter doctor's advice to accept all licenses.
Android Studio's Flutter plugin version too low - simply update it.
Even if you have done everything here,it may not work if you have Android Studio 4.x or canary
It works only in lower version
In my case I only miss Dart plugin so i installed and on IDE restart it was there

Can't build a flutter project with PathProvider dependency

Disclaimer: First of all, this is my early attempt to play with Flutter. So forgive me if is a noob question.
I had been playing with an MVP-Clean architecture for Flutter apps in iOS, and when trying to build a data source where I can persist data easily I found PathProvider plugin.
After trying the next:
Add dependencies to the project
dependencies: path_provider: "^0.4.0"
Provide dependencies
flutter packages get
pod install
I try to compile the project and the compiler shouts:
** BUILD FAILED **
Xcode's output: ↳
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
/proect_directory/ios/Runner/GeneratedPluginRegistrant.m:6:9:
fatal error: 'path_provider/PathProviderPlugin.h' file not found
#import <path_provider/PathProviderPlugin.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
I did a quick search and I did not find anything useful.
Could anyone illuminate my path?
EDIT:
Already tried with:
flutter update-packages --force-upgrade
And the doctor output does not show any errors:
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.1.5, on Mac OS X 10.13.3 17D102, locale
en-ES)
[✓] Android toolchain - develop for Android devices (Android
SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
[✓] Android Studio (version 3.0)
[✓] IntelliJ IDEA Community Edition
(version 2017.3.4)
[✓] Connected devices (1 available)
This issue should be fixed by https://github.com/flutter/flutter/pull/15437
To apply the fix to an existing project, add these lines to ios/Podfile.
I finally find a workaround.
I went to the GitHub repo, found the PathProviderPlugin.h file, and put it inside the location:
build/ios/Debug-iphonesimulator/path_provider/path_provider.framework/Headers/
Sounds a little bit dirty, but was the only way to keep coding.
Hope helps someone. And thanks to #GünterZöchbauer to help me find a useful lead.
Open the project in xcode. i.e On Android Studio, right click -> Flutter -> open in xcode.
Find the PathProviderPlugin.h file. (Find -> Find in workspace -> 3. PathProviderPlugin.h)
Click on the result. In case you cannot find the result, right click on the PathProviderPlugin.m file and choose 'Reveal In Project Navigator'
There you will see PathProviderPlugin.h file.
On right hand side, target membership, change the settings from project to public.
Do this for any files for which compiler is complaining, till you are able to build your project.
Check the image for reference. Use the highlighted button to open right hand panel (Added For Android devs who don't know much of xcode. :) )
i have just deleted the podfile.lock and podfile then i run the command flutter build ios ,it install podfile and podlock perfectly but build was failed because i didnt set the team for provision, so then i came to the terminal of android studio and run the command flutter run and it works!...
For me this was solved by editing podfile as mentioned by this https://github.com/flutter/flutter/issues/10654#issuecomment-389034245 and change the xcode's build system to legacy.
I encountered a similar issue and solved it with these simple steps:
Delete the .pub-cache folder inside the Flutter SDK
From the root directory of the flutter project, command flutter clean then flutter pub get

Resources