question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

issue using --dart-define in run configurations with a value that has a space

See original GitHub issue

Steps to Reproduce

  • Create a flutter app, the template counter app will do
  • Create a run configuration and add the following to the “additional arguments”
--dart-define='SOMETHING=cool: thing'
  • Run the app using the configuration
  • Instead of setting the value in the ENV for SOMETHING='cool: thing' the run configuration fails with an error like this:
Target file "thing'" not found.

Note: this works just fine via the flutter command line

flutter run --dart-define='SOMETHING=cool: thing' -t lib/main.dart

And the value is available in the ENV as expected.

If you remove the empty space character between cool: and thing then it works just fine. Is there some escaping approach for this in Android Studio? Is this an issue with the plugin or Android Studio itself?

Version info

$ flutter doctor -v
[✓] Flutter (Channel unknown, v1.17.0, on Mac OS X 10.15.4 19E287, locale en-US)
    • Flutter version 1.17.0 at /Users/sam/flutter
    • Framework revision d3ed9ec945 (8 weeks ago), 2020-04-06 14:07:34 -0700
    • Engine revision c9506cb8e9
    • Dart version 2.8.0 (build 2.8.0-dev.18.0 eea9717938)


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/sam/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • 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.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] 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)

[✓] VS Code (version 1.44.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.1

[✓] Connected device (4 available)
    • iPhone 11 Pro • BD24122A-D14B-472C-8A26-A436A43E3583 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
    • macOS         • macOS                                • darwin-x64     • Mac OS X
      10.15.4 19E287
    • Chrome        • chrome                               • web-javascript • Google
      Chrome 83.0.4103.61
    • Web Server    • web-server                           • web-javascript • Flutter
      Tools

• No issues found!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dmitry-fbmcommented, Apr 14, 2021

Still doesn’t work:

flutter/bin/flutter build ios --no-codesign --dart-define='DEF_APP_NAME=anything with spaces'
Target file "with" not found.

Flutter 2.0.4 Dart 2.12.2

1reaction
devoncarewcommented, Jan 21, 2021

Yup, we almost always release based on calendar month - it makes planning simple and is predictable for users (modulo the end of the year - we generally don’t ship a Dec. release).

You can also see the est. ship date via our milestones in this repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter android studio --dart-define not working - Stack Overflow
I am trying to pass arguments using --dart-define in the Android Studio IDE, but I am not able to access in the code....
Read more >
Using --dart-define in Flutter - Dart Code
You can pass additional --dart-define values to Flutter by specifying them in the toolArgs field of your launch configuration ( launch.json ):.
Read more >
How to run a Flutter app with arguments in VS Code ... - Sarunw
Learn what launch configuration is and how to use it.
Read more >
How to Store API Keys in Flutter: --dart-define vs .env files
To deal with this, we can use launch configurations. ... package helps us generate a Dart class that contains the values from our...
Read more >
Real-World Flutter by Tutorials, Chapter 1: Setting up Your ...
It sets you up for success by teaching you everything you need to run the ... the dart-define parameter when using flutter run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found