简体   繁体   English

应用程序在使用Google Play服务时遇到问题。 请再试一次

[英]App is having trouble with Google Play Services. Please try again

I have done this code several times. 我已多次完成此代码。 But from today morning i see this problem occurs. 但从今天早上起,我发现这个问题就出现了。 This is a basic code to show a map layout. 这是显示地图布局的基本代码。 And showing this error to me. 并向我显示此错误。 And also I entered the API key correctly. 我也正确地输入了API密钥。 Screen Shot of Emulator I searched for other StackOverflow posts but nothing workes for me. 模拟器的屏幕截图我搜索了其他StackOverflow帖子,但没有什么适合我。

package com.example.maptest

import android.support.v7.app.AppCompatActivity
import android.os.Bundle

import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MarkerOptions

class MapsActivity : AppCompatActivity(), OnMapReadyCallback {

    private lateinit var mMap: GoogleMap

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_maps)
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        val mapFragment = supportFragmentManager
            .findFragmentById(R.id.map) as SupportMapFragment
        mapFragment.getMapAsync(this)
    }

    /**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */
    override fun onMapReady(googleMap: GoogleMap) {
        mMap = googleMap

        // Add a marker in Sydney and move the camera
        val sydney = LatLng(-34.0, 151.0)
        mMap.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney"))
        mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney))
    }
}

Xml file:- Xml文件: -

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:map="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/map"
      tools:context=".MapsActivity"
      android:name="com.google.android.gms.maps.SupportMapFragment"/>

App level gradle:- 应用级别gradle: -

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.maptest"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Project level gradle:- 项目级别: -

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I solved this problem. 我解决了这个问题。

By changing app level gradle dependencies 通过更改应用程序级别gradle依赖项

from this 由此

implementation 'com.google.android.gms:play-services-maps:16.1.0'

to this 对此

implementation 'com.google.android.gms:play-services-maps:16.0.0'

Update: 更新:

Now i can use this latest gradle dependency. 现在我可以使用这个最新的gradle依赖。 It works fine for me. 这对我来说可以。

implementation 'com.google.android.gms:play-services-maps:16.1.0'

I also had this problem and when I changed the dependencies to implementation 'com.google.android.gms:play-services-maps:16.0.0' the map was not loading. 我也有这个问题,当我将依赖项更改为implementation 'com.google.android.gms:play-services-maps:16.0.0' ,地图未加载。

So I updated Google Play Services on my emulator: 所以我在模拟器上更新了Google Play服务:

在此输入图像描述

After that, I had to sign in to access the Play Store and then I could update Google Play Services. 之后,我必须登录才能访问Play商店,然后我可以更新Google Play服务。

Finally, I let the dependency as implementation 'com.google.android.gms:play-services-maps:16.1.0' 最后,我将依赖作为implementation 'com.google.android.gms:play-services-maps:16.1.0'

A little late, but I have been having this issue as well. 有点晚了,但我也遇到过这个问题。 Changing the dependencies as has been suggested here hasn't worked for me. 如此处所建议的那样更改依赖关系并不适用于我。 What did work was actually going into chrome on the emulator and searching for Google Play Services. 工作实际上是在模拟器上进入chrome并搜索Google Play服务。 Click on the suggested link to the app store for it and it should take you to the Play Store in the browser. 单击建议的应用程序商店链接,它将带您进入浏览器中的Play商店。 Click on the button at the bottom to open it in the app store on the emulator (because searching for it in the play store doesn't actually bring it up, you have to go through a browser), and hopefully it gives you the option to update Google Play Services. 点击底部的按钮在模拟器上的应用程序商店中打开它(因为在游戏商店中搜索它实际上没有提起它,你必须通过浏览器),并希望它为您提供选项更新Google Play服务。 It worked perfect for me after that! 之后它对我来说非常完美!

Check that the variant ( release / debug ) that you are building is properly signed... 检查您正在构建的变体( 发布 / 调试 )是否已正确签名...

Right-click module => Open Module settings 右键单击模块 => 打开模块设置
Under Build Types check Signing Config 在“ 构建类型”下,选中“ 签名配置”

api 'com.google.android.gms:play-services-maps:16.1.0'

Above works fine for me in real world - but I don't use the emulator. 以上在现实世界中对我来说很好 - 但我不使用模拟器。

AS 3.3.2 / Plugin 3.3.2 / Gradle 4.10.2 / compileSdkVersion 28 / buildToolsVersion "28.0.3" AS 3.3.2 /插件3.3.2 / Gradle 4.10.2 / compileSdkVersion 28 / buildToolsVersion“28.0.3”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “<app> 在使用 Google Play 服务时遇到问题。 请再试一次”,同时使用 Google NearBy Messages API</app> - “<App> is having trouble with Google Play Services. Please try again” while usiing Google NearBy Messages API 如何解决“应用程序在使用谷歌播放服务时遇到问题。 请再试一次。” - How to resolve “App is having trouble with google play services. please try again.” 应用程序在使用Google Play服务时遇到问题。 如果仍然存在,请联系开发人员以获取帮助 - App is having trouble with Google Play Services. If it persists, please contact the developer for assistance <Your App> Google Play 服务出现问题。请重试。 仅在 4.4.X 操作系统设备上 - <Your App> is having trouble with Google Play services.Please try again. Only on 4.4.X OS devices 更新Google Play服务。 除非您更新Google Play服务,否则此应用无法运行 - Update Google Play services. This app won't run unless you update Google Play services Google Play服务“无法登录。请检查您的网络连接,然后重试” - Google Play Services “Failed to sign in. Please check your network connection and try again” 更新Google Play服务。 除非您更新Google Play服务,否则应用程序将无法运行 - Update Google Play Services. App won't work unless you update google play services 无法登录。 请检查您的网络连接广告,然后重试,Google Play游戏服务 - failed to sign in . Please check your network connection ad try again , google play game services 在android studio中,BasicSamples项目抱怨“除非您更新Google Play服务,否则此应用将无法运行。” - In android studio, the BasicSamples project complains that “This app won't run unless you update Google Play services.” <Your App>使用Google Play服务时出现问题 - 使用GoogleApiClient时,它始终会触发onConnectionFailed - <Your App> is having trouble with Google Play services - When using GoogleApiClient, it always trigger onConnectionFailed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM