0

I want to run the example of google_maps_flutter. So I downloaded the code from https://github.com/flutter/plugins and open the /plugins/tree/master/packages/google_maps_flutter/google_maps_flutter using android studio.

In the README.md file, it said

Usage

To use this plugin, add google_maps_flutter as a dependency in your pubspec.yaml file.

After I added the

dependencies:
  google_maps_flutter: ^1.0.3

it shows

Error on line 11, column 3 of pubspec.yaml: A package may not list itself as a dependency. ╷ 11 │ google_maps_flutter: ^1.0.3 │
^^^^^^^^^^^^^^^^^^^ ╵ pub get failed (65; ╵)

After I changed line 1 from name: google_maps_flutter to name: google_maps_flutter_eg, it shows

Error on line 1, column 7 of ../pubspec.yaml: "name" field doesn't match expected name "google_maps_flutter". ╷ 1 │ name: google_maps_flutter_eg │ ^^^^^^^^^^^^^^^^^^^^^^ ╵ pub get failed (65; ╵)

how can i change the name of this project for me to run the example?

below is the pubspec.yaml

name: google_maps_flutter
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter
version: 1.0.7

dependencies:
  flutter:
    sdk: flutter
  flutter_plugin_android_lifecycle: ^1.0.0
  google_maps_flutter_platform_interface: ^1.0.4
  google_maps_flutter: ^1.0.6

dev_dependencies:
  flutter_test:
    sdk: flutter

  # TODO(iskakaushik): The following dependencies can be removed once
  # https://github.com/dart-lang/pub/issues/2101 is resolved.
  flutter_driver:
    sdk: flutter
  test: ^1.6.0
  pedantic: ^1.8.0
  plugin_platform_interface: ^1.0.2
  mockito: ^4.1.1

flutter:
  plugin:
    platforms:
      android:
        package: io.flutter.plugins.googlemaps
        pluginClass: GoogleMapsPlugin
      ios:
        pluginClass: FLTGoogleMapsPlugin

environment:
  sdk: ">=2.1.0 <3.0.0"
  flutter: ">=1.22.0 <2.0.0"
Matthias
  • 348
  • 3
  • 11

1 Answers1

0

You can't have a dependency that has the same name as your project.You need to change the name.

semih10
  • 11
  • 5
  • could you upload screenshot of pubspec.yaml file? – semih10 Nov 23 '20 at 13:55
  • I suppose that your project name is "google_maps_flutter" ,so i edited my answer. – semih10 Nov 23 '20 at 14:01
  • published pubspec.yaml above. But the original project name google_maps_flutter is the same as the dependency which produces the error. – Matthias Nov 23 '20 at 14:04
  • if you change your project name,error is disappear. – semih10 Nov 23 '20 at 14:08
  • how can i change the project name in android studio? – Matthias Nov 23 '20 at 14:08
  • look at this url : https://stackoverflow.com/questions/18276872/change-project-name-on-android-studio – semih10 Nov 23 '20 at 14:12
  • i did rename the project folder, run flutter clean, then rename the rootProject.name android/settings.gradle and rename the s.name in ios/google_maps_flutter.podspec and still receiving error Error on line 1, column 7 of ../pubspec.yaml: "name" field doesn't match expected name "google_maps_flutter". – Matthias Nov 23 '20 at 14:45
  • You also have to rename the `name` property in your `pubspec.yaml` file to your the name of your project folder. – jabamataro Dec 02 '20 at 04:19