W/GooglePlayServicesUtil(16928):缺少 Google Play 商店。颤动

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

我正在尝试获取用户位置,但是当我没有在我的应用程序中使用任何谷歌应用程序或服务时,谷歌游戏商店服务丢失了。帮助 我每次都会收到此错误,我尝试获取我当前的位置 我用 -----> 标记了它 它应该给我纬度和经度

W/GooglePlayServicesUtil(16928): Google Play Store is missing. flutter

这是我的主要代码我试图点击前缀图标来获取我的位置

import 'package:flutter/material.dart';
import 'package:project/screens/sign_page.dart';
import 'package:project/screens/home_screen.dart';
import 'package:geolocator/geolocator.dart';

//textediting controller needed to be added
// Define a custom Form widget.
class MyCustomForm extends StatefulWidget {
  const MyCustomForm({Key? key}) : super(key: key);

  @override
  MyCustomFormState createState() {
    return MyCustomFormState();
  }
}

// Define a corresponding State class.
// This class holds data related to the form.
class MyCustomFormState extends State<MyCustomForm> {
  final _formKey = new GlobalKey<FormState>();
  getcurrentlocation() async {
    Position position = await Geolocator.getCurrentPosition(
        desiredAccuracy: LocationAccuracy.high);
    var latitude = position.latitude;
    var longitude = position.longitude;

    print(latitude);
    print(longitude);
  }

  TextEditingController name = TextEditingController();
  TextEditingController phone = TextEditingController();
  TextEditingController address = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Material(
        child: Form(
            key: _formKey,
            child: SafeArea(
              child: Column(
                children: [
                  Container(
                    height: MediaQuery.of(context).size.height * 0.15,
                    width: double.infinity,
                    decoration: BoxDecoration(
                        image: DecorationImage(
                            image: AssetImage("assets/images/background.png"),
                            fit: BoxFit.cover)),
                    padding: EdgeInsets.only(top: 47, left: 20),
                    child: Text(
                      "Personal info",
                      style: TextStyle(
                          fontSize: 45,
                          fontWeight: FontWeight.bold,
                          color: Colors.white),
                    ),
                  ),
                  SizedBox(
                    height: 20,
                  ),
                  Container(
                    alignment: Alignment.topLeft,
                    padding: EdgeInsets.only(left: 29),
                    child: Text(
                      "Name",
                      style: TextStyle(fontSize: 18, color: Colors.black),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.symmetric(horizontal: 25, vertical: 20),
                    child: TextFormField(
                      keyboardType: TextInputType.name,
                      controller: name,
                      onFieldSubmitted: (value) {},
                      validator: (value) {
                        if (value!.isEmpty) {
                          return 'Enter a valid Name!';
                        }
                        return null;
                      },
                      decoration: InputDecoration(
                        filled: true,
                        isDense: true, // Added this
                        contentPadding: EdgeInsets.symmetric(vertical: 22),
                        fillColor: Color.fromRGBO(238, 247, 246, 1),
                        enabledBorder: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(12.0)),
                          borderSide: BorderSide(color: Colors.white, width: 2),
                        ),

                        hintText: '',
                      ),
                    ),
                  ),
                  Container(
                    alignment: Alignment.topLeft,
                    padding: EdgeInsets.only(left: 29),
                    child: Text(
                      "Address",
                      style: TextStyle(fontSize: 18, color: Colors.black),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.symmetric(horizontal: 25, vertical: 20),
                    child: TextFormField(
                      keyboardType: TextInputType.text,
                      controller: address,
                      onFieldSubmitted: (value) {},
                      validator: (value) {
                        if (value!.isEmpty) {
                          return 'Enter a valid address!';
                        }
                        return null;
                      },
                      decoration: InputDecoration(
                        prefixIcon: IconButton(
                          onPressed: () async {
                            getcurrentlocation();     **----->here!**
                          },
                          icon: Icon(Icons.location_on),
                        ),
                        isDense: true, // Added this
                        contentPadding: EdgeInsets.symmetric(vertical: 22),
                        filled: true,

                        fillColor: Color.fromRGBO(238, 247, 246, 1),
                        enabledBorder: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(12.0)),
                          borderSide: BorderSide(color: Colors.white, width: 2),
                        ),

                        hintText: '',
                      ),
                    ),
                  ),
                  Container(
                    alignment: Alignment.topLeft,
                    padding: EdgeInsets.only(left: 29),
                    child: Text(
                      "Phone Number",
                      style: TextStyle(fontSize: 18, color: Colors.black),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.symmetric(horizontal: 25, vertical: 15),
                    child: TextFormField(
                      keyboardType: TextInputType.number,
                      controller: phone,
                      onFieldSubmitted: (value) {},
                      validator: (value) {
                        if (value!.isEmpty) {
                          return 'Enter a valid phone number!';
                        }
                        return null;
                      },
                      decoration: InputDecoration(
                        isDense: true, // Added this
                        contentPadding: EdgeInsets.symmetric(vertical: 22),
                        filled: true,

                        fillColor: Color.fromRGBO(238, 247, 246, 1),
                        enabledBorder: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(12.0)),
                          borderSide: BorderSide(color: Colors.white, width: 2),
                        ),
                        hintText: '',
                      ),
                    ),
                  ),
                  Expanded(child: Text("")),
                  FlatButton(
                    height: 50,
                    minWidth: 300,
                    onPressed: () {
                      if (_formKey.currentState!.validate()) {
                        Navigator.push(context,
                            MaterialPageRoute(builder: (_) => homeScreen()));
                        // If the form is valid, display a snackbar. In the real world,
                        // you'd often call a server or save the information in a database.
                        ScaffoldMessenger.of(context).showSnackBar(
                          SnackBar(content: Text("")),
                        );
                      }
                    },
                    color: const Color.fromRGBO(0, 168, 165, 1),
                    shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(10)),
                    child: const Text(
                      "Continue",
                      style: TextStyle(color: Colors.white, fontSize: 19),
                    ),
                  ),
                  SizedBox(
                    height: 20,
                  )
                ],
              ),

              // Add TextFormFields and ElevatedButton here.
            )));
  }
}

flutter dart location
2个回答
1
投票

我认为您可以在没有 Playstore 的情况下使用模拟器运行应用程序。 Google core 需要在您的虚拟设备上安装 google play 才能获得广告地图和包含 google play SDK 的核心功能。

您只需要创建一个带有 google play 的模拟器,如下图所示,其中一个带有 google play 图标。 我希望这个答案对你有帮助。.


0
投票

您需要使用包含 Google Play 应用程序的模拟器。 所以,如果你不这样做,你应该创建一个模拟器。您可以在 Play Store 栏中查看 Google Play 是否存在。

© www.soinside.com 2019 - 2024. All rights reserved.