Codemagic: how do I set up integration tests Android Emulator - flutter

Here is how the default configuration for tests looks like:
In Flutter Drive arguments we can see that there is a target defined
drive --target=test_driver/main.dart
Flutter documentation on integration tests doesn't mention creating this file. So this folder with the respective file is missing in my project, which logically results into fail:
Target file "test_driver/main.dart" not found.
Here are the logs:
> flutter devices
3 connected devices:
Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
macOS (desktop) • macos • darwin-x64 • macOS 12.4 21F79 darwin-x64
Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114
> flutter -d emulator-5554 drive --target=test_driver/main.dart
Target file "test_driver/main.dart" not found.
The documentation on how to write integration tests only mentions test_driver when testing web.
Apparently I am either missing stuff in my project or I need to configure codemagic workflow differently.
There is a bit information here https://docs.codemagic.io/yaml-testing/testing/ for yaml configuration. Should i switch to yaml config, or can it be done from CodeMagic UI?
UPDATE:
After I have change the configuration as mentioned in the answers to this:
The logs are now:
Test file not found: > /Users/builder/clone/test_driver/app_test_test.dart

The recommended approach per Flutter documentation is to use:
flutter test integration_test
Thus, in the arguments section in Codemagic, just add test integration_test.

test_driver/main.dart is just a placeholder. Flutter documentation covered this in step 3. Create the test files
And in Codemagic you need to specify drive --target=integration_test/app_test.dart

Related

Flutter / Dart syntax highlighting is not working

The syntax of the dartcode in my flutter project is no longer being highlighted and cannot click the declarations or do autocomplete of code, like typing: StreamBuilder( and then click enter to create the widget for a streambuilder.
See example code below, where normaly, the different elements would be coloured:
This problem occured after I installed intelliJ, I did this because I needed to write some javascript for firebase functions.
Tried this so far, with no luck:
deleting android studio and re-install it.
invalidate caches and restart.
restart analyses server
checked that dart and flutter has the right paths under 'languages & frameworks'
created a new flutter project, here everything works just fine. but if i copy in my codebase the issue persists
Im using android studios latest version.
EDIT:
Apparently I have some issues after all with the plugins. But as seen in the picture, I've given the paths to both flutter and dart.
Its somehow related to intelliJ because when i click the links from the flutter doctor output it takes me to jetbrains website
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.3 20E232 darwin-x64, locale da-DK)
• Flutter version 2.2.3 at /Users/jeffmayn/Desktop/Development/flutter
• Framework revision f4abaa0735 (10 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/jeffmayn/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 15.0.1+9-18)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.1
[✓] 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 10 (API 29) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.63
! Doctor found issues in 2 categories.
Process finished with exit code 0
I think reinstalling Flutter and Dart plugin to Android Studio can help. Syntax highlighting is plugins' job.
The solution of yoppuyoppu worked for me, but as he mentioned, only for the selected files.
So here is a small addition that makes it work for all .dart files:
In the "Register New File Type Association" window you can change the File pattern to "*.dart".
And of course select Dart as shown.
That way all files ending with ".dart" will be associated with Dart.
In my case, only one file had such problem. And it turned out I screwed up the file type association of the file when I created it.
Fix was to reassociate the file with Dart.
Go to the menu bar >> File >> File Properties >> Associate with File Type...
And in the dialog that follows, pick Dart and click OK.
You can choose as many files as you like at any one time.
None of the suggested solutions worked out for me. What I did was then:
create a new flutter project.
setup dart and flutter plugins.
copy in all my code, files, assets, etc. from the old project to the new.

"flutter web is currently not supported"

I'm making a website in flutter web
When I use the command
webdev serve
Everything works, but when I use the command
flutter build web
I get this error:
Downloading Web SDK... 1,6s
"build web" is not currently supported.
This is my flutter version
[✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Mac OS X 10.15 xxxx, locale xxx)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.40.0)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
Thanks in advance!
I also faced the same issue.
Follow the official documentation
In my case, I missed to execute the following command
> flutter config --enable-web
Also, ensure that you are in the 'Dev' channel
flutter channel dev
Flutter 1.9 has early support for web application and the message seems to say you're not using a channel which has the web development
Did you change the channel to be able to build your web application: flutter channel dev, upgrade flutter, enable web in the configuration?
I don't use webdev serve but flutter run -d chrome
When running flutter doctor -v, you should have something like:
[✓] Flutter (Channel master, v1.10.15-pre.272, on Mac OS X 10.13.4 17E199, locale fr-FR)
• Flutter version 1.10.15-pre.272 at /Users/erictaix/development/tools/flutter
• Framework revision 5bc7fb6835 (13 days ago), 2019-10-27 21:25:13 -0700
• Engine revision 3ebf006904
• Dart version 2.6.0 (build 2.6.0-dev.8.2 6354b0b97d)
...
[✓] Connected device (3 available)
• macOS • macOS • darwin-x64 • Mac OS X 10.13.4 17E199
• Chrome • chrome • web-javascript • Google Chrome 78.0.3904.97
• Web Server • web-server • web-javascript • Flutter Tools
Note that flutter use master channel on my computer (dev should work) and in connected devices, you can see Chrome and Web Server.
My version is 1.10 because as mentioned, I use the channel master which is not stable at all. But with dev channel it should work. Please refer to the documentation for up-to-date instructions: https://flutter.dev/docs/get-started/web

Flutter fresh installation flutter run stuck

I am new to flutter i have fresh installtion.
All as in docs.
As after fresh installation i was fine worked but when i want to work on another day flutter run i stuck.... I do not know why. I only make boilerplate app. I xcode when i build app is opening in simulator but stating as flutter run not working. I even try to wait 20 min with this flutter run but still stuck
flutter doctor -v
[✓] Flutter (Channel master, v1.6.4-pre.14, on Mac OS X 10.14.5 18F132, locale
pl-PL)
• Flutter version 1.6.4-pre.14 at /Users/db/Desktop/Mobile/flutter
• Framework revision 81c38b22cb (32 hours ago), 2019-05-24 22:51:02 -0400
• Engine revision 8dc3a4cde2
• Dart version 2.3.2 (build 2.3.2-dev.0.0 e3edfd36b2)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/db/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.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_152-release-1343-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.0
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 35.3.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b01)
[✓] Connected device (1 available)
• iPhone 8 • F35EFD3E-C637-427A-8405-30EDF202939A • ios •
com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
• No issues found!
flutter run -v stuck at this stage.
+file:///Users/db/Desktop/Mobile/flutter/packages/flutter/lib/widgets.d
art
[ ] -> +file:///Users/db/Desktop/Flutter/iamsmart/lib/main.dart
[ ] -> 35191e22-84d6-4fab-abef-178ae9e4c665 build/app.dill 0
[ +319 ms] Building bundle
[ ] Writing asset files to build/flutter_assets
[ +55 ms] Wrote build/flutter_assets
[ +12 ms] Using legacy Xcode build system.
[ +27 ms] executing: [/Users/db/Desktop/Flutter/iamsmart/ios/]
/usr/bin/xcodebuild -list
Run this command
flutter clean
And then again
flutter run
Try to upgrade your flutter version to v 1.7.8 by running this
command this needs internet connection
flutter upgrade
Try this command
flutter clean
Change your flutter channel to stable
flutter channel stable
Check your internet connection because sometimes it prevents me from
running my app
Try to switch your flutter channel master to stable channel. After switching the channels you should call flutter upgrade to download the Flutter SDK and dependent packages.
Do this steps in the terminal
flutter channel stable
flutter upgrade
try to run your code after this steps.
Update to 1.9.1-hotfix4 fixed the problem
Your flutter doctor isn't showing any error as you had shared the commands.I think to share the run command terminal so that we can find out the stack of flowing of commands.
If you are getting error to build flutter project then you should update the Android Studio or VS Code Editor.
You can refer here:
Android studio-https://developer.android.com/studio
VS Code-https://code.visualstudio.com/Download
If you are able to create flutter project but doesn't getting run command then you need to update flutter and dart.
You can refer here:
Flutter-https://flutter.dev/docs/development/tools/sdk/releases
Dart-https://dart.dev/get-dart
If still you are suffering from error then you need to share some more Pics.
Probably something's gone wrong after you changed some files in of flutter ide. Also it does after updates crashed.
So the thing you should do is firstly backup your projects if it indeed. After backup remove the ide and be sure uninstalling complate succesful. Restart your computer and install all decencies again. Because sometimes upgrading does not works well to get good result.
P.S : Dont forget using flutter doctor for checking if any problem comes out.

Flutter no devices detected even the simulator is on

I am a totally rookie in flutter project development and recently i have run into a tech issue that the flutter can not detect the android simulator even the simulator is on ;
The issue as below:
enter image description here
Flutter console:
F:\Developer\demo>flutter doctor -v
[√] Flutter (Channel beta, v0.7.3, on Microsoft Windows [Version 10.0.17134.228], locale zh-CN)
• Flutter version 0.7.3 at D:\flutter_windows_v0.7.3-beta\flutter
• Framework revision 3b309bda07 (3 months ago), 2018-08-28 12:39:24 -0700
• Engine revision af42b6dc95
• Dart version 2.1.0-dev.1.0.flutter-ccb16f7282
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at D:\Android\android-sdk-windows
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = D:\Android\android-sdk-windows
• Java binary at: D:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
• All Android licenses accepted.
[√] Android Studio (version 3.1)
• Android Studio at D:\Program Files\Android\Android Studio
• Flutter plugin version 28.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[!] Connected devices
! No devices available
! Doctor found issues in 1 category.
So, is there anything i am going wrong?
First check if your devices were listed:
In terminal, run the flutter devices command to verify that Flutter
recognizes your connected Android device.
You can follow the installation guide provided in the Flutter documentation:
Windows set-up
Install Android
Studio
Download and install Android Studio.
Start Android Studio, and go through the ‘Android Studio Setup Wizard’. This installs the latest Android SDK, Android SDK
Command-line Tools, and Android SDK Build-Tools, which are required by
Flutter when developing for Android.
Set up your Android
device
To prepare to run and test your Flutter app on an Android device, you
need an Android device running Android 4.1 (API level 16) or higher.
Enable Developer options and USB debugging on your device. Detailed instructions are available in the Android
documentation.
Windows-only: Install the Google USB Driver.
Using a USB cable, plug your phone into your computer. If prompted on your device, authorize your computer to access your device.
n the terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device. By default, Flutter
uses the version of the Android SDK where your adb tool is based. If
you want Flutter to use a different installation of the Android SDK,
you must set the ANDROID_SDK_ROOT environment variable to that
installation directory.
Set up the Android
emulator
To prepare to run and test your Flutter app on the Android emulator,
follow these steps:
Enable VM
acceleration
on your machine.
Launch Android Studio, click the AVD Manager icon, and select Create
Virtual Device…
In older versions of Android Studio, you should instead launch Android Studio > Tools > Android > AVD Manager and select Create Virtual Device…. (The Android submenu is only present when
inside an Android project.)
If you do not have a project open, you can choose Configure > AVD Manager and select Create Virtual Device…
Choose a device definition and select Next.
Select one or more system images for the Android versions you want to emulate, and select Next. An x86 or x86_64 image is
recommended.
Under Emulated Performance, select Hardware - GLES 2.0 to enable hardware
acceleration.
Verify the AVD configuration is correct, and select Finish.
For details on the above steps, see Managing AVDs.
In Android Virtual Device Manager, click Run in the toolbar. The emulator starts up and displays the default canvas for your
selected OS version and device.
Try to check this SO post as well. It is related to your question.

Android SDK is missing command line tools

I've installed flutter but when I run flutter doctor to verify the installation, I get:-
Android SDK is missing command line tools
I've doubled checked that the command lines are installed.
What do I need to do remove this error?
I've included the full flutter doctor -v output below:-
$ flutter doctor -v
[✓] Flutter (Channel beta, v0.3.1, on Mac OS X 10.13.4 17E202, locale en-AU)
• Flutter version 0.3.1 at /Users/chris/flutter
• Framework revision 12bbaba9ae (2 weeks ago), 2018-04-19 23:36:15 -0700
• Engine revision 09d05a3891
• Dart version 2.0.0-dev.48.0.flutter-fe606f890b
[!] Android toolchain - develop for Android devices
• Android SDK at /usr/local/Caskroom/android-platform-tools/27.0.1
• Android NDK location not configured (optional; useful for native profiling support)
• ANDROID_HOME = /usr/local/Caskroom/android-sdk/3859397
✗ Android SDK is missing command line tools;
• Try re-installing or updating your Android SDK,
visit https://flutter.io/setup/#android-setup for detailed instructions.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.3, Build version 9E145
• ios-deploy 1.9.2
• CocoaPods version 1.5.0
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 24.1.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.2)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 24.1.2
• Dart plugin version 181.4668.60
[!] Connected devices
! No devices available
! Doctor found issues in 2 categories.
On Android Studio open SDK Manager.
Go to SDK Tools tab.
Check if Android SDK Command-line Tools is checked. If not, check and apply the changes.
For some reason, after updating flutter and Android Studio, I got this error too. Seems like some new requirement that for some reason wasn't automatically installed.
This fixed it for me.
I think ANDROID_HOME and ANDROID SDK should be pointing to the same path and that is the SDK's root directory.
In my .bashrc (on LINUX), following are
export ANDROID_HOME=/home/myname/Android/Sdk
export PATH=/home/myname/Android/Sdk:$PATH
export PATH=/home/myname/Android/Sdk/platform-tools:$PATH
export PATH=/home/myname/Android/Sdk/tools:$PATH
export PATH=/home/myname/Android/ndk-build:$PATH
Just solved the problem. Here are my system settings:
System variable ANDROID_SDK_ROOT points to my Android SDK dir
In system Path variable, I have sdk/tools, sdk/platform-tools, and /flutter-dir/bin
Also make sure you don't have dulplicated directories. I previously downloaded another platform-tools and add it to Path, so I had to delete it and use the sdk's one.
After changing those things, I close the flutter cmd windows and run flutter doctor on PowerShell. Worked like a charm!
Please download the latest sdk build-tools to solve the problem of Android SDK is missing command line tools