[Breaking change] The URLLauncher and PathProvider classes have been moved to plugins

6,073 views
Skip to first unread message

Michael Thomsen

unread,
May 9, 2017, 2:02:55 PM5/9/17
to Flutter Dev, Sarah Zakarias
The URLLauncher and PathProvider classes have been removed from services.dart. They are now published as Flutter plugins on the Pub repository.

During this change their functions were moved to the global namespace, so you no longer need a URLLauncher. or PathProvider. prefix when invoking their methods.

What to change

If you are using URLLauncher, or PathProvider, or both, you need to:
  1. Update the pubspec.yaml file, located in the root directory of your app, to declare a dependency on url_launcher and/or path_provider.
    See https://flutter.io/platform-plugins/#example for a concrete example.

  2. Add a corresponding import statement(s) in your main program:
    import 'package:url_launcher/url_launcher.dart';
    and/or
    import 'package:path_provider/path_provider.dart';

  3. Change all method calls to no longer use the class prefix.

    For example, change:
      UrlLauncher.launch('https://flutter.io');
    to:
      launch('https://flutter.io');

  4. and change:
      String dir = (await PathProvider.getApplicationDocumentsDirectory()).path;
    to:
      String dir = (await getApplicationDocumentsDirectory()).path;


Please do not hesitate to contact us, if you need any help adjusting your code to this change.

Andreas Reuterberg

unread,
May 10, 2017, 5:12:09 AM5/10/17
to Flutter Dev
I'm sure I'm doing something wrong here, adding url_launcher works fine for me, but when I try using path_provider I get this error:

cannot find symbol
PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.path_provider.PathProviderPlugin"));

What am I missing?

/Andreas

Christian Rivasseau

unread,
May 10, 2017, 5:27:51 AM5/10/17
to Andreas Reuterberg, Flutter Dev
I find that you shall also update your settings.gradle with:


def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withInputStream { stream -> plugins.load(stream) }
}

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}

as it is done here:
https://github.com/flutter/flutter/blob/master/examples/platform_channel/android/settings.gradle

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Christian Rivasseau
Co-founder and CTO @ Lefty
+33 6 67 35 26 74

Andreas Reuterberg

unread,
May 10, 2017, 5:56:59 AM5/10/17
to Flutter Dev
Thanks for the reply! It seems that file was already updated, so there must be something else I'm missing.

I don't suppose there's some "clean all plugins" command? I'll try and create a new project and see if the plugin works in there.

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Taylor Ren

unread,
May 10, 2017, 6:20:05 AM5/10/17
to Flutter Dev
This change IS breaking...as it breaks one of my key files:

Followed the instruction and after a clean rebuild, it works again. 

Hope there won't be such drastic changes without a proper notice!

Christian Rivasseau

unread,
May 10, 2017, 6:25:53 AM5/10/17
to Taylor Ren, Flutter Dev
This was a very proper notice :)

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Thomsen

unread,
May 10, 2017, 6:32:48 AM5/10/17
to Andreas Reuterberg, Flutter Dev
I am very sorry, but we made a mistake and forgot to publish a needed change to path_provider. This is our fault, not you doing anything wrong.

Please stay tuned, and we will have this fixed shortly.

On Wed, May 10, 2017 at 11:12 AM, Andreas Reuterberg <andreas.r...@gmail.com> wrote:

--

Michael Thomsen

unread,
May 10, 2017, 8:23:16 AM5/10/17
to Andreas Reuterberg, Flutter Dev
An updated version of path_provider has been published. To resolve the issue you were seeing:
  1. Run:
      
    flutter packages upgrade
    in your app dir

  2. confirm that you got version 0.2.0 by running
      cat pubspec.lock
We will get shared_preferences upgraded now.

Andreas Reuterberg

unread,
May 10, 2017, 9:36:36 AM5/10/17
to Flutter Dev
Thank you! That fixes the previous issue I had and I can compile and run the code. But at runtime, when calling their methods, I get an error for both plugins:

MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher)
MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)

Maybe this is something on my end, at least?
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

Michael Thomsen

unread,
May 10, 2017, 9:40:07 AM5/10/17
to Andreas Reuterberg, Flutter Dev
Android or iOS or both?

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

Michael Thomsen

unread,
May 10, 2017, 9:51:39 AM5/10/17
to Andreas Reuterberg, Flutter Dev
I'm pretty sure that is a sign you are missing the changes from the other breaking change from yesterday:

If that doesn't work either, it could be any number of files that are no longer in sync with what we currently have in head of flutter/flutter. One way to check would be to create a new app with `flutter create` and diff the files in the android and ios subfolders.

Ian Hickson

unread,
May 10, 2017, 10:15:58 AM5/10/17
to Taylor Ren, Flutter Dev


On Wed, May 10, 2017, 3:20 AM Taylor Ren <taylo...@gmail.com> wrote:
This change IS breaking...as it breaks one of my key files:

Followed the instruction and after a clean rebuild, it works again. 

Hope there won't be such drastic changes without a proper notice!

Our goal is to greatly reduce the number of such changes going forward. We've been making a of changes recently specifically to resolve the issues we know are outstanding.

In general going forward you should expect that only features that are relatively new will risk being broken, anything that has existed for a while should be stable.

We beg for your indulgence as we adapt to this new regime!



--

--
Ian Hickson

😸

Christian Rivasseau

unread,
May 10, 2017, 10:27:35 AM5/10/17
to Ian Hickson, Taylor Ren, Flutter Dev
Hi, under xCode I have the error that

#import "PathProviderPlugin.h"

#import "UrlLauncherPlugin.h"


are not found. Do you know how to add them to xCode?


Thanks,


--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jakob Roland Andersen

unread,
May 10, 2017, 11:10:36 AM5/10/17
to Christian Rivasseau, Ian Hickson, Flutter Dev, Taylor Ren
Did you open Runner.xcworkspace in Xcode?

If you did, could you try running 'flutter -v build ios', and verify that it runs a 'pod install' step? That should get the plugin pods added to the workspace, so the headers are available.

If you opened Runner.xcodeproj, then open the workspace instead. 

ons. 10. maj 2017 kl. 16.27 skrev Christian Rivasseau <chri...@lefty.io>:
Hi, under xCode I have the error that

#import "PathProviderPlugin.h"

#import "UrlLauncherPlugin.h"


are not found. Do you know how to add them to xCode?


Thanks,

On Wed, May 10, 2017 at 4:15 PM, Ian Hickson <i...@hixie.ch> wrote:


On Wed, May 10, 2017, 3:20 AM Taylor Ren <taylo...@gmail.com> wrote:
This change IS breaking...as it breaks one of my key files:

Followed the instruction and after a clean rebuild, it works again. 

Hope there won't be such drastic changes without a proper notice!

Our goal is to greatly reduce the number of such changes going forward. We've been making a of changes recently specifically to resolve the issues we know are outstanding.

In general going forward you should expect that only features that are relatively new will risk being broken, anything that has existed for a while should be stable.

We beg for your indulgence as we adapt to this new regime!



--

--
Ian Hickson

😸

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Christian Rivasseau
Co-founder and CTO @ Lefty
+33 6 67 35 26 74

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

Christian Rivasseau

unread,
May 10, 2017, 12:26:47 PM5/10/17
to Jakob Roland Andersen, Ian Hickson, Flutter Dev, Taylor Ren

I can see the install phase but it doesn't look like the path_provider and url_launcher are in the list of deps?


   +1 ms] Creating service definitions manifest at 'ios/ServiceDefinitions.json'

[ +192 ms] Found plugin path_provider at /Users/lefty/.pub-cache/hosted/pub.dartlang.org/path_provider-0.2.0/

[  +74 ms] Found plugin url_launcher at /Users/lefty/.pub-cache/hosted/pub.dartlang.org/url_launcher-0.4.1/

[  +53 ms] pod --version

[ +725 ms] pod --version

[ +433 ms] Exit code 0 from: pod --version

[        ] 1.2.0

[   +5 ms] Running pod install...

[   +1 ms] [ios/] pod install

[+5027 ms] Analyzing dependencies

                   Downloading dependencies

                   Using Firebase (3.13.0)

                   Using FirebaseAnalytics (3.7.0)

                   Using FirebaseAuth (3.1.1)

                   Using FirebaseCore (3.5.0)

                   Using FirebaseDatabase (3.1.2)

                   Using FirebaseInstanceID (1.0.9)

                   Using GTMSessionFetcher (1.1.8)

                   Using GoogleToolboxForMac (2.1.1)

                   Generating Pods project

                   Integrating client project

                   Sending stats

                   Pod installation complete! There are 3 dependencies from the Podfile and 8 total pods installed.

[  +15 ms] Running Xcode build...


On Wed, May 10, 2017 at 5:10 PM, Jakob Roland Andersen <jak...@google.com> wrote:
Did you open Runner.xcworkspace in Xcode?

If you did, could you try running 'flutter -v build ios', and verify that it runs a 'pod install' step? That should get the plugin pods added to the workspace, so the headers are available.

If you opened Runner.xcodeproj, then open the workspace instead. 
ons. 10. maj 2017 kl. 16.27 skrev Christian Rivasseau <chri...@lefty.io>:
Hi, under xCode I have the error that

#import "PathProviderPlugin.h"

#import "UrlLauncherPlugin.h"


are not found. Do you know how to add them to xCode?


Thanks,

On Wed, May 10, 2017 at 4:15 PM, Ian Hickson <i...@hixie.ch> wrote:


On Wed, May 10, 2017, 3:20 AM Taylor Ren <taylo...@gmail.com> wrote:
This change IS breaking...as it breaks one of my key files:

Followed the instruction and after a clean rebuild, it works again. 

Hope there won't be such drastic changes without a proper notice!

Our goal is to greatly reduce the number of such changes going forward. We've been making a of changes recently specifically to resolve the issues we know are outstanding.

In general going forward you should expect that only features that are relatively new will risk being broken, anything that has existed for a while should be stable.

We beg for your indulgence as we adapt to this new regime!



--

--
Ian Hickson

😸

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Christian Rivasseau
Co-founder and CTO @ Lefty
+33 6 67 35 26 74

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jakob Roland Andersen

unread,
May 10, 2017, 12:53:07 PM5/10/17
to Christian Rivasseau, Flutter Dev, Ian Hickson, Taylor Ren
Your Podfile might need to get updated. Could you compare it to one from a fresh new project? It should have a section that reads .flutter-plugins and adds pods for the plugins. 

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Christian Rivasseau
Co-founder and CTO @ Lefty
+33 6 67 35 26 74

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Christian Rivasseau

unread,
May 10, 2017, 1:03:22 PM5/10/17
to Jakob Roland Andersen, Flutter Dev, Ian Hickson, Taylor Ren
That was it thanks,

In order to get the plugins to work under iOS I had to edit my Podfile and make it look like



To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Christian Rivasseau
Co-founder and CTO @ Lefty
+33 6 67 35 26 74

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Christian Rivasseau
Co-founder and CTO @ Lefty
+33 6 67 35 26 74

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Taylor Ren

unread,
May 10, 2017, 6:09:10 PM5/10/17
to Flutter Dev
Just a piece of my penny-worth-input, I did have the same issue "No implementation found for method..." when I tried to use the new launch plugin in my Android emulator. 

After a clean rebuild, i.e., deleted the `build` directory and then run `flutter run` again, the generated debug app is running OK. 

Taylor Ren

unread,
May 10, 2017, 6:22:57 PM5/10/17
to Flutter Dev
Hi Ian,

Thanks for the feedback.

This is the first reply that with a sincere attitude. 

No, I am not challenging that the Flutter team should NOT make such changes. Being a user from Dart, and now Flutter, I understand that a new language should have such iterations to make itself better. 

What I have in mind is that: 

1. If such a change is unavoidable, will it be better to prompt in the compiler a "Deprecated" notice and guide the end developer to something useful (like this thread or the thread prompting the encouraged, new way)? 

2. And then after the next few upgrades of Flutter SDK, totally remove the deprecated notice and the implementation of the deprecated package/class/method?

I call this a "phase-in" transition (and now it is a "cut-in" change).

Ian Hickson

unread,
May 10, 2017, 7:47:20 PM5/10/17
to Taylor Ren, Flutter Dev
Yup, this is exactly the approach we want to take going forward.

You can actually see that we have started doing this, e.g. just yesterday we marked TwoLevelList as deprecated:
https://docs.flutter.io/flutter/material/TwoLevelList-class.html

We're still learning exactly how this should work.

You can see our official policy on breaking changes here:

It's still evolving (I just added a paragraph about @deprecated in fact). Please don't hesitate to call us out when we make a mistake!

Cheers,

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

--
Ian Hickson

😸

dmitry....@jetbrains.com

unread,
May 22, 2017, 10:30:21 PM5/22/17
to Flutter Dev, za...@google.com

I think I did what was required to migrate my code, but I still get an exception:

E/flutter (18496): NoSuchMethodError: The method '~/' was called on null.
E/flutter (18496): Receiver: null
E/flutter (18496): Tried calling: ~/(16.0)
E/flutter (18496): #0      Object._noSuchMethod (dart:core-patch/object_patch.dart:43)
E/flutter (18496): #1      Object.noSuchMethod (dart:core-patch/object_patch.dart:47)
E/flutter (18496): #2      EditorState._sendScrollViewport (package:xi_widgets/src/editor.dart:308)
E/flutter (18496): #3      EditorState.initState.<anonymous closure> (package:xi_widgets/src/editor.dart:126)
E/flutter (18496): #4      _microtaskLoop (dart:async/schedule_microtask.dart:41)
E/flutter (18496): #5      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
E/flutter (18496): [ERROR:../../lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (18496): MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)
E/flutter (18496): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:139)
E/flutter (18496): <asynchronous suspension>
E/flutter (18496): #1      getTemporaryDirectory (package:path_provider/path_provider.dart:23)
E/flutter (18496): <asynchronous suspension>


What am I missing?

Mikkel Ravn

unread,
May 23, 2017, 1:42:39 AM5/23/17
to dmitry....@jetbrains.com, Flutter Dev, Sarah Zakarias
The MissingPluginException indicates that no method call handler is attached to the channel on the host platform. One way this could happen is if your iOS AppDelegate or main Android Activity do not ask the (auto-)GeneratedPluginRegistrant to register itself.


--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Mikkel Nygaard Ravn
Software Engineer

Message has been deleted
Message has been deleted

Christian Rivasseau

unread,
Jun 5, 2017, 3:17:25 AM6/5/17
to jo...@harpsoft.com, Flutter Dev

is this on iOS or Android?


Le lun. 5 juin 2017 01:23, <jo...@harpsoft.com> a écrit :
I have also added the line (but plugin still not found):
GeneratedPluginRegistrant.registerWith(this);


On Saturday, June 3, 2017 at 11:00:41 PM UTC-5, Joel Trunick wrote:
I have this issue as well, did you figure out how to resolve?

Joel

Mikkel Ravn

unread,
Jun 5, 2017, 8:54:48 AM6/5/17
to Christian Rivasseau, Joel Trunick, Flutter Dev
Seems to be Android based on the syntax: GeneratedPluginRegistrant.registerWith(this);

Joel, did you launch your app using flutter run? If not, please try that. Flutter build tooling is needed at least once after plugin dependency changes to have those dependencies copied from pubspec.yaml and into platform-specific build scripts and the GeneratedPluginRegistrant. Using Android Studio or Xcode should work after that.

If it still doesn't work, could you relay the contents of GeneratedPluginRegistrant.java and output from flutter doctor?

jo...@harpsoft.com

unread,
Jun 5, 2017, 10:39:50 PM6/5/17
to Flutter Dev, chri...@lefty.io, jo...@harpsoft.com
I just got the iOS part working as well. I had some calls in didFinishLaunchingWithOptions that appear should not be present any longer:

//    FlutterDartProject* project = [[FlutterDartProject alloc] initFromDefaultSourceForConfiguration];

//    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

rock...@gmail.com

unread,
Dec 28, 2017, 10:31:51 PM12/28/17
to Flutter Dev
Not sure if my issue is related to this.

Reply all
Reply to author
Forward
0 new messages