错误:“I/进程 (26960):正在发送信号。PID:26960 SIG:9 与设备的连接丢失。”在 android studio 上使用 flutter 时

问题描述 投票:0回答:4

输入这段代码后,每次我尝试运行该程序时,我都会得到这个
“I/进程(26960):发送信号。PID:26960 SIG:9
与设备失去连接。

下面是代码块。我已经添加了完成这项工作所需的所有权限和依赖项,但我仍然遇到这个错误。请帮助我(我使用 Windows)。

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

class HomeTabPage extends StatelessWidget
{
  Completer<GoogleMapController> _controllerGoogleMap = Completer();
  GoogleMapController newGoogleMapController;

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

  Position currentPosition;
  var geolocator = Geolocator();


  void locatePosition() async
  {
    Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    currentPosition = position;

    LatLng intLatPosition = LatLng(position.latitude, position.longitude);

    CameraPosition cameraPosition = new CameraPosition(target: intLatPosition, zoom: 14);
    newGoogleMapController.animateCamera(CameraUpdate.newCameraPosition(cameraPosition));

    //String address = await AssistantMethods.searchCoordinateAddress(position, context);
    //print("This is your Address :: " + address);

  }

  @override
  Widget build(BuildContext context)
  {
    return Stack(
      children: [
        GoogleMap(
          mapType: MapType.normal,
          myLocationButtonEnabled: true,
          initialCameraPosition: _kGooglePlex,
          myLocationEnabled: true,
          onMapCreated: (GoogleMapController controller)
          {
            _controllerGoogleMap.complete(controller);
            newGoogleMapController = controller;

            locatePosition();
          },
        ),
      ],
    );
  }
}

firebase android-studio flutter google-maps geolocation
4个回答
10
投票

好吧,我将其留在这里,以防其他人遇到同样的问题。我添加了

android.enableDexingArtifactTransform=false

到 gradle.properties 并且它起作用了。

查看 https://github.com/flutter/flutter/issues/72185 了解更多详情


2
投票

嗨,也许是因为权限访问,请将这行代码添加到您的/android/app/src/main/AndroidManifest.xml

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

0
投票

main.dart async 中创建 main 函数,它在我的案例中有效


0
投票

就我而言,我使用的是 Google Ads Mobile,但忘记将以下内容添加到我的 app/build.gradle 文件中:

    implementation 'com.google.android.gms:play-services-ads:19.7.1'
    implementation 'com.android.support:multidex:1.0.3'
© www.soinside.com 2019 - 2024. All rights reserved.