Flutter-询问附近地点时出现错误 [英] Flutter- Getting and error when asking for Nearbyplaces

查看:146
本文介绍了Flutter-询问附近地点时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Flutter中实现Google Map和附近的Search,但我几乎做到了,但是我不明白尝试获取位置附近的地点时遇到的错误.

我在网上搜索,但无法弄清楚,谁能告诉我出什么问题了.我在网上寻找修复程序的时间损失了将近2小时,但一无所获.

这是代码:

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

class MapScreen extends StatefulWidget {
  @override
  _MapScreenState createState() => _MapScreenState();
}

class _MapScreenState extends State<MapScreen> {
  GoogleMapController mapController;
  var googlePlace = GooglePlace("");
  //this are the longitude and the latitude of the phone
  double lng;
  double lat;


  void _onMapCreated(GoogleMapController controller) {
    mapController = controller;
    getPosition().then((value) => getLocationNearBy());
  }

  Future<Position> getPosition() async {
    LocationPermission permission = await checkPermission();
    LocationPermission permission2 = await requestPermission();
    Position position =
        await getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    lat = position.latitude;
    lng = position.longitude;
    print(position);
    return position;
  }

  void getLocationNearBy() async {
    var result = await googlePlace.search
        .getNearBySearch(Location(lat: lat, lng: lng), 2000, type: "bars");
    print(result);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: GoogleMap(
          myLocationEnabled: true,
          myLocationButtonEnabled: true,
          onMapCreated: _onMapCreated,
          initialCameraPosition: CameraPosition(
            target: _center,
            zoom: 11.0,
          ),
        ),
      ),
    );
  }
}

这是错误:

 Considering local module com.google.android.gms.googlecertificates:0 and remote module 

com.google.android.gms.googlecertificates:6
I/DynamiteModule(18683): Selected remote version of com.google.android.gms.googlecertificates, version >= 6
I/DynamiteLoaderV2Impl(18683): [71] Googlecertificates
W/m.example.ipil(18683): ClassLoaderContext type mismatch. expected=PCL, found=DLC (PCL[] | DLC[];PCL[/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk*4144957280:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes2.dex*3286414090:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes3.dex*660981783:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes4.dex*371746816:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes5.dex*1029310577:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes6.dex*1730292004:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes7.dex*2560797352:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes8.dex*1790620740:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes9.dex*2957673897:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes10.dex*1136895787:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes11.dex*1461101890:/data/app/com
W/m.example.ipil(18683): Found duplicate classes, falling back to extracting from APK : /data/user_de/0/com.google.android.gms/app_chimera/m/000000d4/GoogleCertificates.apk
W/m.example.ipil(18683): NOTE: This wastes RAM and hurts startup performance.
W/m.example.ipil(18683): Found duplicated class when checking oat files: 'Landroidx/annotation/Keep;' in /data/user_de/0/com.google.android.gms/app_chimera/m/000000d4/GoogleCertificates.apk and /data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes13.dex
W/m.example.ipil(18683): 
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/m.example.ipil(18683): NativeAlloc concurrent copying GC freed 83801(6328KB) AllocSpace objects, 143(8420KB) LOS objects, 49% free, 7253KB/14MB, paused 211us total 141.179ms
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 3 lines
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 2 lines
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 1 line
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 5 lines
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 4 lines

解决方案

要解决此问题,请确保您在pubspec.yaml中没有软件包位置,同时在google.services.gms中没有软件包位置. >

Hi I want to implement Google Map and nearby Search in Flutter and I almost did it but I don't understand the error that I'm getting while trying to fetch the places near my position.

I searched online but I couldn't figure it out, can anyone tell me what is wrong please. I lost almost 2h searching the web for the fix but nothing.

This is the code :

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

class MapScreen extends StatefulWidget {
  @override
  _MapScreenState createState() => _MapScreenState();
}

class _MapScreenState extends State<MapScreen> {
  GoogleMapController mapController;
  var googlePlace = GooglePlace("");
  //this are the longitude and the latitude of the phone
  double lng;
  double lat;


  void _onMapCreated(GoogleMapController controller) {
    mapController = controller;
    getPosition().then((value) => getLocationNearBy());
  }

  Future<Position> getPosition() async {
    LocationPermission permission = await checkPermission();
    LocationPermission permission2 = await requestPermission();
    Position position =
        await getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    lat = position.latitude;
    lng = position.longitude;
    print(position);
    return position;
  }

  void getLocationNearBy() async {
    var result = await googlePlace.search
        .getNearBySearch(Location(lat: lat, lng: lng), 2000, type: "bars");
    print(result);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: GoogleMap(
          myLocationEnabled: true,
          myLocationButtonEnabled: true,
          onMapCreated: _onMapCreated,
          initialCameraPosition: CameraPosition(
            target: _center,
            zoom: 11.0,
          ),
        ),
      ),
    );
  }
}

This is the error:

 Considering local module com.google.android.gms.googlecertificates:0 and remote module 

com.google.android.gms.googlecertificates:6
I/DynamiteModule(18683): Selected remote version of com.google.android.gms.googlecertificates, version >= 6
I/DynamiteLoaderV2Impl(18683): [71] Googlecertificates
W/m.example.ipil(18683): ClassLoaderContext type mismatch. expected=PCL, found=DLC (PCL[] | DLC[];PCL[/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk*4144957280:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes2.dex*3286414090:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes3.dex*660981783:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes4.dex*371746816:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes5.dex*1029310577:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes6.dex*1730292004:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes7.dex*2560797352:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes8.dex*1790620740:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes9.dex*2957673897:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes10.dex*1136895787:/data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes11.dex*1461101890:/data/app/com
W/m.example.ipil(18683): Found duplicate classes, falling back to extracting from APK : /data/user_de/0/com.google.android.gms/app_chimera/m/000000d4/GoogleCertificates.apk
W/m.example.ipil(18683): NOTE: This wastes RAM and hurts startup performance.
W/m.example.ipil(18683): Found duplicated class when checking oat files: 'Landroidx/annotation/Keep;' in /data/user_de/0/com.google.android.gms/app_chimera/m/000000d4/GoogleCertificates.apk and /data/app/com.example.ipill-sEbMOSkwYUXtrKfO0SfLPQ==/base.apk!classes13.dex
W/m.example.ipil(18683): 
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/m.example.ipil(18683): NativeAlloc concurrent copying GC freed 83801(6328KB) AllocSpace objects, 143(8420KB) LOS objects, 49% free, 7253KB/14MB, paused 211us total 141.179ms
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 3 lines
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 2 lines
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 1 line
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 5 lines
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.example.ipil(18683): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
I/chatty  (18683): uid=10378(com.example.ipill) GoogleApiHandle identical 4 lines

解决方案

To solve this problem make sure you don't have the package location in your pubspec.yaml and at the same time, google.services.gms.

这篇关于Flutter-询问附近地点时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆