web-dev-qa-db-fra.com

L'application rencontre des problèmes avec les services Google Play. Veuillez réessayer

J'ai fait ce code plusieurs fois. Mais à partir d'aujourd'hui matin, je vois ce problème se produire. Il s'agit d'un code de base pour afficher une disposition de carte. Et en me montrant cette erreur. Et j'ai également entré la clé API correctement . Capture d'écran de l'émulateur J'ai cherché d'autres publications StackOverflow mais rien ne fonctionne pour moi.

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))
    }
}

Fichier 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"/>

Gradle au niveau de l'application: -

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'
}

Niveau de projet: -

    // 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
}
12
Debashis Nandy

Un peu tard, mais j'ai aussi eu ce problème. Changer les dépendances comme cela a été suggéré ici n'a pas fonctionné pour moi. Ce qui a fonctionné se passait réellement dans chrome sur l'émulateur et recherche de services Google Play. Cliquez sur le lien suggéré vers l'App Store pour cela et il devrait vous amener au Play Store dans le navigateur Cliquez sur le bouton en bas pour l'ouvrir dans l'App Store sur l'émulateur (parce que sa recherche dans le Play Store ne le fait pas apparaître, vous devez passer par un navigateur), et j'espère que cela vous donne la option pour mettre à jour les services Google Play. Cela a fonctionné parfaitement pour moi après cela!

0
pianoman102