Creating a Flutter Windows Desktop Build from GitLab Shared Runners - flutter

I am working on a CI pipeline for my flutter desktop app, currently it's Windows only but this will soon change to be Windows/Linux. I was planning to use the GitLab shared runners with the cirrusci/flutter docker image to automate this.
Unfortunately, when running the command I am greeted with this log:
"build windows" only supported on Windows hosts.
Which makes total sense, since flutter builds native apps and likely requires the SDKs.
I was wondering if anyone is familiar with how to set up a pipeline for Windows desktop applications to be built. I can switch GitLab to use a Windows shared runner, but this doesn't have a flutter install.
Just wondering what the path of least resistance is here.. I've reached the end of my surface-level understanding of these systems (Docker + GitLab CI)
Thank you,
David

I'm trying to do the same. I took this project as an example https://gitlab.com/famedly/fluffychat/-/blob/main/.gitlab-ci.yml
I ended up with a job looking like this (in the .gitlab-ci.yml):
build_test_app_win_job:
stage: build
tags:
- shared-windows
- windows
- windows-1809
before_script:
# Install flutter (using Chocolatey and confirming all prompts)
- choco install flutter --confirm --no-progress
- Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
- refreshenv
# Disable Google Analytics report for Flutter
- flutter config --no-analytics
script:
- cd test_app/
- flutter pub get
- flutter build windows -v >> debugCiLog.txt
However I'm stuck with a weird error during build (despite all being ok on my local computer):
[ +321 ms] C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(231,5): error MSB6006: "cmd.exe" exited with code 1. [C:\GitLab-Runner\builds\TestProject\test_app\build\windows\flutter\flutter_assemble.vcxproj]
With verbose on:
[ +74 ms] [ +8 ms] Error parsing assemble command: your generated configuration may be out of date. Try re-running 'flutter build ios' or the appropriate build command.
[ +8 ms] [ +3 ms]
[ ] #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
[ ] #1 AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:295:7)
[ ] #2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1374:12)
[ ] <asynchronous suspension>
[ ] #3 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1209:27)
[ ] <asynchronous suspension>
[ ] #4 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[ ] <asynchronous suspension>
[ ] #5 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
[ ] <asynchronous suspension>
[ ] #6 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
[ ] <asynchronous suspension>
[ ] #7 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[ ] <asynchronous suspension>
[ ] #8 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
[ ] <asynchronous suspension>
[ ] #9 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
[ ] <asynchronous suspension>
[ ] #10 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[ ] <asynchronous suspension>
[ ] #11 main (package:flutter_tools/executable.dart:91:3)
[ ] <asynchronous suspension>
[ +2 ms] [ +67 ms] "flutter assemble" took 621ms.
[ ] [ +5 ms] ensureAnalyticsSent: 2ms
[ ] [ +1 ms] Running shutdown hooks
[ ] [ ] Shutdown hooks complete
[ ] [ +6 ms] exiting with code 1
The following error is probably wrong, I can not find something relevant on google (I have no space or special character in the path):
Error parsing assemble command: your generated configuration may be out of date. Try re-running 'flutter build ios' or the appropriate build command.
Maybe this can help you despite I fail on my setup. I would be interested if you have more success than me 😉
Also, I try flutter doctor and all seems ok:
Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.6.4)
Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.17763.1339], locale en-US)

Related

Incompatible types: MainActivity cannot be converted to FlutterEngine, GeneratedPluginRegistrant.registerWith(this);

I had an old project kind off like a POC 2-3 years old in flutter,
Now when I try to run it on the latest version I get the following error:
On Flutter Run:
/Users/jci/Documents/Projects/Flutter/dicee/android/app/src/main/java/co/appbrewery/dicee/MainActivity.java:11: error: incompatible types: MainActivity cannot be converted to FlutterEngine
GeneratedPluginRegistrant.registerWith(this);
^
Note: /Users/jci/Documents/Projects/Flutter/dicee/android/app/src/main/java/co/appbrewery/dicee/MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 21s
Exception: Gradle task assembleDebug failed with exit code 1
Flutter Run -v:
[ +1 ms] /Users/jci/Documents/Projects/Flutter/dicee-flutter/android/app/src/main/java/co/appbrewery/dicee/MainActivity.java:11: error: incompatible types:
MainActivity cannot be converted to FlutterEngine
[ +2 ms] GeneratedPluginRegistrant.registerWith(this);
[ ] ^
[ ] Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
[ ] 1 error
[ ] FAILURE: Build failed with an exception.
[ ] * What went wrong:
[ ] Execution failed for task ':app:compileDebugJavaWithJavac'.
[ ] > Compilation failed; see the compiler error output for details.
[ ] * 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
[ ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
[ ] Use '--warning-mode all' to show the individual deprecation warnings.
[ ] See https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings
[ ] 17 actionable tasks: 5 executed, 12 up-to-date
[ +379 ms] Running Gradle task 'assembleDebug'... (completed in 4.3s)
[+2421 ms] Exception: Gradle task assembleDebug failed with exit code 1
[ +1 ms] "flutter run" took 21,908ms.
[ +3 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:699:9)
<asynchronous suspension>
#2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27)
<asynchronous suspension>
#3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#4 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#5 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10 main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>
Not quite certain if it's a single error or multiple, my guess is it has something to do with my gradle any help whatsoever is appreciated.
It's been a while since I have not checked flutter so I am not sure what the error means...
After putting in some hours into this I realized that the issue was with my Activity having the old flutter engine config code, to fix this all i had to do was go from this:
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
where it was registering PluginRegistrant to that:
import io.flutter.embedding.android.FlutterActivity;
public class MainActivity extends FlutterActivity {
}
More information in the Flutter Github Upgradation document

Flutter VS Code Emulator stuck at Running Gradle task 'assembleDebug'

Since yesterday evening I've been unable to open my app in emulator. It worked fine till then.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart:1
√ Built build\app\outputs\flutter-apk\app-debug.apk.
It usually takes about 2 mins to open but it was just stuck there for like 15 mins. So I looked up for answers and the first one said to use gradlew clean and gradlew build. I did that and still was stuck but with another error.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart:1
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_android-2.0.12\android\src\main\java\io\flutter\plugins\pathprovider\PathProviderPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Then I tried an answer from a similar question here that suggested to do flutter pub cache repair. Still no luck.
Then I tried another suggestion from an answer here to upgrade flutter. I hadn't upgraded flutter for a couple months since so I did that but still the issue persists.
I read from a comment to a question here that when they run the project using flutter run -v in terminal it opened up after about 20 mins. So I started it and because my laptop is like 6 years old running 6th gen i5 with 8gb ram I thought it might take a bit longer. So I left it there and now after about 2 hours my terminal is stuck at:
I hit the question character limit so I put the terminal's output in
an online notepad at: https://anotepad.com/notes/3jri4gpc
I just closed the emulator and the terminal added this to the above
[+7331895 ms] executing: C:\Users\hp\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell pm list packages com.example.myapp
[ +90 ms] adb.exe: device offline
[ +27 ms] ProcessException: Process exited abnormally:
adb.exe: device offline
Command: C:\Users\hp\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell pm list packages com.example.myapp
[ +3 ms] Installing APK.
[ +17 ms] Installing build\app\outputs\flutter-apk\app.apk...
[ +8 ms] executing: C:\Users\hp\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 install -t -r
D:\myapp\front\myapp\build\app\outputs\flutter-apk\app.apk
[ +114 ms] Performing Push Install
adb: error: failed to get feature set: device 'emulator-5554' not found
[ +6 ms] Installing build\app\outputs\flutter-apk\app.apk... (completed in 115ms)
[ +5 ms] Error: ADB exited with exit code -1
[ +4 ms] Performing Push Install
adb: error: failed to get feature set: device 'emulator-5554' not found
[ +1 ms] Warning: Failed to install APK.
[ +4 ms] Error launching application on Android SDK built for x86.
[ +9 ms] "flutter run" took 7,368,695ms.
[ +23 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:687:9)
<asynchronous suspension>
#2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1161:27)
<asynchronous suspension>
#3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#4 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#5 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10 main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>
[ +172 ms] ensureAnalyticsSent: 163ms
[ +10 ms] Running shutdown hooks
[ +2 ms] Shutdown hooks complete
[ +2 ms] exiting with code 1
From [+7331895 ms] executing: in the first line after closing the emulator I can see that this was running for about 122 minutes.
I don't understand what's wrong here. Why did the emulator stop working normally all of a sudden?
How to make it work so that I can continue with my app development? Please help.

Could not resolve all artifacts for configuration ':classpath' in flutter

Yesterday i woke up and found my Visual studio misbehaving. I had to delete all my file in .graddle folder and then re-download them but it's giving the errors below, i have tried googling for solutions but all in vain.
I am using Graddle:
gradle-6.7-all.zip
I am using linux mint distro.
-Pfilesystem-scheme=org-dartlang-root assembleDebug
[+454406 ms] FAILURE: Build failed with an exception.
[ +7 ms] * What went wrong:
[ +1 ms] A problem occurred configuring root project 'android'.
[ +1 ms] > Could not resolve all artifacts for configuration ':classpath'.
[ +2 ms] > Could not download builder-4.1.0.jar (com.android.tools.build:builder:4.1.0)
[ +1 ms] > Could not get resource
'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/4.1.0/builder-4.1.0.jar'.
[ +9 ms] > Premature end of Content-Length delimited message body (expected: 9,546,513; received: 4,456,416)
[ +2 ms] > Could not download kotlin-compiler-embeddable-1.3.50.jar
(org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.50)
[ +11 ms] > Could not get resource
'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.3.50/kotlin-compiler-embeddable-1.3.50.jar'.
[ +4 ms] > Premature end of Content-Length delimited message body (expected: 36,615,572; received: 4,456,416)
[ +1 ms] > Could not download fastutil-7.2.0.jar (it.unimi.dsi:fastutil:7.2.0)
[ +2 ms] > Could not get resource 'https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.jar'.
[ +5 ms] > Premature end of Content-Length delimited message body (expected: 17,309,408; received: 6,553,552)
[ +2 ms] * Try:
[ +2 ms] 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.
[ +3 ms] * Get more help at https://help.gradle.org
[ +1 ms] BUILD FAILED in 7m 33s
[ +627 ms] Running Gradle task 'assembleDebug'... (completed in 455.5s)
[ +10 ms] Exception: Gradle task assembleDebug failed with exit code 1
[ +4 ms] "flutter run" took 461,160ms.
[ +14 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:644:9)
<asynchronous suspension>
#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1157:12)
<asynchronous suspension>
#3 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1009:27)
<asynchronous suspension>
#4 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#5 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#6 CommandRunner.runCommand (package:args/command_runner.dart:197:13)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:278:9)
<asynchronous suspension>
#8 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#9 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#10 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:234:5)
<asynchronous suspension>
#11 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
<asynchronous suspension>
#12 run.<anonymous closure> (package:flutter_tools/runner.dart:62:12)
<asynchronous suspension>
#13 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#14 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#15 runInContext (package:flutter_tools/src/context_runner.dart:73:10)
<asynchronous suspension>
#16 main (package:flutter_tools/executable.dart:90:3)
<asynchronous suspension>
[ +260 ms] ensureAnalyticsSent: 252ms
[ +3 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ +14 ms] Shutdown hooks complete
[ +1 ms] exiting with code 1

Flutter not building the android dependencies

Folks,
I am re-building an already built flutter application upon changing of the laptop. However I have strangely observed that the dependencies that we mention in the pubspec, not all of them are getting compiled. Those ones which has native dependencies and eventually have android code base in the dependencies fail to compile. I am cluless how this is happening and where should i look forward to get this going. The only error I get is as below. The contentious dependencies were share and connectivity
warning: [options] source value 7 is obsolete and will be removed in a future release
[ +5 ms] warning: [options] target value 7 is obsolete and will be removed in a future release
[ +1 ms] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
[ +1 ms] error: warnings found and -Werror specified
[ +190 ms] FAILURE: Build failed with an exception.
[ ] * What went wrong:
[ ] Execution failed for task ':share:compileDebugJavaWithJavac'.
[ +97 ms] > Compilation failed; see the compiler error output for details.
[ ] * 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.
[ +3 ms] * Get more help at https://help.gradle.org
[ +1 ms] BUILD FAILED in 1m 41s
[ +1 ms] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
[ +1 ms] Use '--warning-mode all' to show the individual deprecation warnings.
[ +5 ms] See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
[ ] 410 actionable tasks: 4 executed, 406 up-to-date
[ +794 ms] Running Gradle task 'assembleDebug'... (completed in 103.9s)
[ +9 ms] Exception: Gradle task assembleDebug failed with exit code 1
[ +4 ms] "flutter run" took 1,08,191ms.
[ +9 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:607:7)
<asynchronous suspension>
#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:977:18)
<asynchronous suspension>
#3 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:836:33)
<asynchronous suspension>
#4 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart)
#5 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
#6 _rootRun (dart:async/zone.dart:1190:13)
#7 _CustomZone.run (dart:async/zone.dart:1093:19)
#8 _runZoned (dart:async/zone.dart:1630:10)
#9 runZoned (dart:async/zone.dart:1550:10)
#10 AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#11 FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:825:20)
#12 CommandRunner.runCommand (package:args/command_runner.dart:197:27)
#13 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:335:21)
#14 _rootRunUnary (dart:async/zone.dart:1198:47)
#15 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#16 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#17 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#18 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#19 Future._completeWithValue (dart:async/future_impl.dart:529:5)
#20 Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#21 _rootRun (dart:async/zone.dart:1190:13)
#22 _CustomZone.run (dart:async/zone.dart:1093:19)
#23 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#24 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#25 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#26 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#27 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#28 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
[ +6 ms] ensureAnalyticsSent: 3ms
[ +3 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ +12 ms] Shutdown hooks complete
[ +1 ms] exiting with code 1
I am using flutter 1.22.6 stable
dart 2.10.5
Gradle 6.5
I have tried it out with 1.22.3 and also with 1.20.4, still this is not taking me anywhere. All that it ends up is not compiling the dependencies having android code in it. gradlew assembleDebug --info and likes of it has resulted in me understanding that the java symbols are not created which eventually are not found by the compilation script, hence it is generating error.
things ive done so far:
run with --no-sound-null-safety and --verbose
find dependencies that complain and check for updates, then update to latest in pubspec
one dependency complained about android min sdk version in gradle.build, so i updated accordingly
now i can build to my test machine and work out the runtime bugs!
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Flutter

Flutter - Running flutter fails, Could not find a file named "pubspec.yaml", Update - (OS Error: Access is denied. , errno = 5)

I just solved all the necessary dependencies.
Building flutter tool...
Running pub upgrade...
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.7.3, on Microsoft Windows [Version 10.0.17134.228], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[√] Android Studio (version 3.1)
[√] IntelliJ IDEA Community Edition (version 2018.2)
[√] Connected devices (1 available)
Now when I try running the flutter app on Android Studio I get this.
A:\Project\flutter_app>flutter run
fatal: Not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Running "flutter packages get" in flutter_app...
Could not find a file named "pubspec.yaml" in "C:\".
pub get failed (66)
Does anyone know what to do to resolve this issue?
[Update 2 hours later]
I deleted flutter and reinstalled in *C:\flutter* using the git repo
https://github.com/flutter/flutter.git
Now the error I am getting is this
A:\Project\flutter_app>flutter run
fatal: Not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Running "flutter packages get" in flutter_app...
Cannot open file, path = '.\pubspec.lock' (OS Error: Access is denied.
, errno = 5)
pub get failed (66)
Update: I tried using verbose when running flutter packages upgrade -v and got this
C:\flutter\flutter_app>flutter packages upgrade -v
fatal: Not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
[ +31 ms] executing: [C:\Users\Nick\flutter\] git rev-parse --abbrev-ref --symbolic #{u}
[ +76 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic #{u}
[ +1 ms] origin/beta
[ ] executing: [C:\Users\Nick\flutter\] git rev-parse --abbrev-ref HEAD
[ +45 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ +1 ms] beta
[ ] executing: [C:\Users\Nick\flutter\] git ls-remote --get-url origin
[ +38 ms] Exit code 0 from: git ls-remote --get-url origin
[ +9 ms] https://github.com/flutter/flutter.git
[ ] executing: [C:\Users\Nick\flutter\] git log -n 1 --pretty=format:%H
[ +38 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[ +1 ms] 3b309bda072a6b326e8aa4591a5836af600923ce
[ +7 ms] executing: [C:\Users\Nick\flutter\] git log -n 1 --pretty=format:%ar
[ +37 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[ +1 ms] 9 days ago
[ ] executing: [C:\Users\Nick\flutter\] git describe --match v*.*.* --first-parent --long --tags
[ +41 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[ +1 ms] v0.7.3-0-g3b309bda0
[ +170 ms] Running "flutter packages upgrade" in flutter_app...
[ +10 ms] executing: [C:\flutter\flutter_app\] C:\Users\Nick\flutter\bin\cache\dart-sdk\bin\pub.bat --verbosity=warning --verbose upgrade --no-precompile
[+16555 ms] Cannot open file, path = '.\pubspec.lock' (OS Error: Access is denied.
[ +1 ms] , errno = 5)
[ +46 ms] Running "flutter packages upgrade" in flutter_app... (completed)
[ +15 ms] "flutter upgrade" took 16,687ms.
pub upgrade failed (66)
#0 throwToolExit (package:flutter_tools/src/base/common.dart:26:3)
#1 pub (package:flutter_tools/src/dart/pub.dart:170:5)
<asynchronous suspension>
#2 pubGet (package:flutter_tools/src/dart/pub.dart:104:13)
<asynchronous suspension>
#3 PackagesGetCommand._runPubGet (package:flutter_tools/src/commands/packages.dart:59:11)
<asynchronous suspension>
#4 PackagesGetCommand.runCommand (package:flutter_tools/src/commands/packages.dart:82:11)
<asynchronous suspension>
#5 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:356:18)
#6 _asyncThenWrapperHelper.<anonymous closure> (dart:async/runtime/libasync_patch.dart:77:64)
#7 _rootRunUnary (dart:async/zone.dart:1132:38)
#8 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#9 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#10 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#11 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#12 Future._complete (dart:async/future_impl.dart:476:7)
#13 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#14 _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async/runtime/libasync_patch.dart:33:20)
#15 _rootRun (dart:async/zone.dart:1124:13)
#16 _CustomZone.run (dart:async/zone.dart:1021:19)
#17 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#18 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#19 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#20 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#21 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
Created GitHub issue https://github.com/flutter/flutter/issues/21495
Update: Not much has improved
#pskink asked me to create a new app in an empty directory while using verbose
Output:
C:\flutter>flutter create flutter_app -v
fatal: Not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Multiple output directories specified.
Try moving -v to be immediately following create
#0 throwToolExit (package:flutter_tools/src/base/common.dart:26:3)
#1 CreateCommand.runCommand (package:flutter_tools/src/commands/create.dart:106:7)
<asynchronous suspension>
#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:356:18)
#3 _asyncThenWrapperHelper.<anonymous closure> (dart:async/runtime/libasync_patch.dart:77:64)
#4 _rootRunUnary (dart:async/zone.dart:1132:38)
#5 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#6 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#8 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#9 Future._complete (dart:async/future_impl.dart:476:7)
#10 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#11 _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async/runtime/libasync_patch.dart:33:20)
#12 _rootRun (dart:async/zone.dart:1124:13)
#13 _CustomZone.run (dart:async/zone.dart:1021:19)
#14 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#15 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#17 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#18 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
Don't copy .packages over from one machine to another. (It should be in .gitignore if using git.)
Instead, run flutter packages get on the mac, and it will recreate .packages.
(Don't copy .flutter-plugins either.)
Delete .packages
Delete pubspec.lock
Run below command shown in image
I assume this is caused by and outdated Git client.
Please ensure you only have one Git client in your PATH and that it is in a recent version.
I found a temporary solution. When I run the same command on Power Shell as an administrator it doesn't show any error.
PS C:\flutter\flutter_app> flutter packages get
fatal: not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Running "flutter packages get" in C:\... 16.1s
PS C:\flutter\flutter_app> flutter packages upgrade
fatal: not a git repository (or any of the parent directories): .git
Building flutter tool...
Running pub upgrade...
Running "flutter packages upgrade" in C:\... 86.9s
kill dart.exe, try run
if still error,
after kill, reopen android studio as admin
Delete app/.packages file from your project and use flutter upgrade to get packages again.
This problem was related to my antivirus program. It worked when I uninstalled the block. Maybe it will help. I wish everybody good work
The same thing happened with me. But in my case I had set the property of the project folder to hidden. When I set that to unhide it started working.