Flutter возвращает указанный дисплей не может быть найден - PullRequest
0 голосов
/ 05 мая 2020

Я создал Google API и могу правильно определить свое местоположение (не включено в этот поток). Основная проблема заключается в том, что когда я пытаюсь добавить простой виджет GoogleMap в свое приложение, в котором вы нашли документы https://pub.dev/packages/google_maps_flutter.

Думаю, мне что-то не хватает, но я следил за каждым шагом и я не могу добавить этот виджет нигде.

У меня эта ошибка стека при попытке создать виджет GoogleMaps в моем проекте

Restarted application in 1,849ms.
I/Google Maps Android API(25357): Google Play services package version: 201216040
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
E/MethodChannel#flutter/platform_views(25357): Failed to handle method call
E/MethodChannel#flutter/platform_views(25357): android.view.WindowManager$InvalidDisplayException: Unable to add window android.view.ViewRootImpl$W@a119084 -- the specified display can not be found
E/MethodChannel#flutter/platform_views(25357):  at android.view.ViewRootImpl.setView(ViewRootImpl.java:1065)
E/MethodChannel#flutter/platform_views(25357):  at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:397)
E/MethodChannel#flutter/platform_views(25357):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:105)
E/MethodChannel#flutter/platform_views(25357):  at android.app.Dialog.show(Dialog.java:340)
E/MethodChannel#flutter/platform_views(25357):  at android.app.Presentation.show(Presentation.java:252)
E/MethodChannel#flutter/platform_views(25357):  at io.flutter.plugin.platform.VirtualDisplayController.<init>(VirtualDisplayController.java:93)
E/MethodChannel#flutter/platform_views(25357):  at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:53)
E/MethodChannel#flutter/platform_views(25357):  at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:105)
E/MethodChannel#flutter/platform_views(25357):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:96)
E/MethodChannel#flutter/platform_views(25357):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
E/MethodChannel#flutter/platform_views(25357):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#flutter/platform_views(25357):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#flutter/platform_views(25357):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#flutter/platform_views(25357):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter/platform_views(25357):  at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#flutter/platform_views(25357):  at android.os.Looper.loop(Looper.java:176)
E/MethodChannel#flutter/platform_views(25357):  at android.app.ActivityThread.main(ActivityThread.java:7464)
E/MethodChannel#flutter/platform_views(25357):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views(25357):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
E/MethodChannel#flutter/platform_views(25357):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
I/chatty  (25357): uid=10153(com.example.timap) GoogleApiHandle identical 33 lines
W/m.example.tima(25357): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
E/flutter (25357): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Unable to add window android.view.ViewRootImpl$W@a119084 -- the specified display can not be found, null)

У меня есть собственный код с виджетом GoogleMap с моим собственным местоположением, но я пытаюсь упростить все, что я закончил, используя тот же код, что и пример google_maps_flutter, и получаю ту же ошибку

main.dart

import 'package:flutter/material.dart';
import 'package:timap/src/pages/home_page.dart';
import 'package:timap/src/pages/lalalala.dart';
import 'package:timap/src/pages/match_details_page.dart';
import 'package:timap/src/pages/matches_page.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Timap',
      routes: {
        'home': (BuildContext context) => HomePage(),
        'matches': (BuildContext context) => MatchesPage(),
        'mapSample': (BuildContext context) => MapSample()
      },
      // initialRoute: 'home',
      initialRoute: 'mapSample',
    );
  }
}

lalalala.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';


class MapSample extends StatefulWidget {
  @override
  State<MapSample> createState() => MapSampleState();
}

class MapSampleState extends State<MapSample> {
  Completer<GoogleMapController> _controller = Completer();

  static final CameraPosition _kGooglePlex = CameraPosition(
    target: LatLng(37.42796133580664, -122.085749655962),
    zoom: 14.4746,
  );

  static final CameraPosition _kLake = CameraPosition(
      bearing: 192.8334901395799,
      target: LatLng(37.43296265331129, -122.08832357078792),
      tilt: 59.440717697143555,
      zoom: 19.151926040649414);

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: GoogleMap(
        mapType: MapType.hybrid,
        initialCameraPosition: _kGooglePlex,
        onMapCreated: (GoogleMapController controller) {
          _controller.complete(controller);
        },
      ),
      floatingActionButton: FloatingActionButton.extended(
        onPressed: _goToTheLake,
        label: Text('To the lake!'),
        icon: Icon(Icons.directions_boat),
      ),
    );
  }

  Future<void> _goToTheLake() async {
    final GoogleMapController controller = await _controller.future;
    controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
  }
}

Мой pubspe c .yaml

name: timap
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  share: ^0.6.4
  social_share: ^2.0.4
  font_awesome_flutter: ^8.8.1
  uuid: ^2.0.4
  faker: ^1.2.1
  intl: ^0.16.1
  google_maps_flutter: ^0.5.27
  geolocator: ^5.3.1
  location_permissions: ^2.0.5
  shared_preferences: ^0.5.7



dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  assets:
    - assets/images/

Мой androidManifest. xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.timap">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />    

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="timap"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="myapikeySecret"/>


    </application>
</manifest>

и мой доктор трепетания

[flutter] flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Linux, locale en_US.UTF-8)
    • Flutter version 1.12.13+hotfix.9 at /home/chubutin/dev/bin/flutter
    • Framework revision f139b11009 (5 weeks ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /home/chubutin/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = /home/chubutin/Android/Sdk
    • Java binary at: /home/chubutin/dev/ide/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.

[✓] Android Studio (version 3.6)
    • Android Studio at /home/chubutin/dev/ide/android-studio
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.44.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.10.1

[✓] Connected device (1 available)
    • sdk gphone x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

! Doctor found issues in 1 category.
...