dapriett / nativescript-google-maps-sdk

Cross Platform Google Maps SDK for Nativescript
MIT License
244 stars 169 forks source link

<AppName> is having trouble with Google Play services. Please try again. #339

Closed dlcole closed 5 years ago

dlcole commented 5 years ago

I've been receiving the subject error message on Android emulators, so I created a minimal Google maps app - only displays an empty map - and I receive the same error.

I created a Stack Overflow post, but with no answers. Now that I've recreated the error with the only plugin being google-maps-sdk, I'm opening an issue here. I'd love to get this fixed soI can return to testing on Android emulators.

kylawamg commented 5 years ago

I have the same issue...any updates? thanks!

dlcole commented 5 years ago

For what it's worth, this sure looks like an Android Studio emulator problem. That said, I've created multiple new emulators with various API levels, all with the same result. I've also specified various versions of Google Play Services, but again, no joy. I'm hoping someone can at least find a bypass. I'll continue to poke at it.

tylerablake commented 5 years ago

Hey @dlcole and @kylawamg I got this to work, here's what I did.

  1. Make sure Google Play services is enabled/installed inside of Android Studio Click SDK Manager in the top right of Android Studio to see the following: image

It should prompt for a download after you check the box and hit apply.

  1. Add the following line in your AndroidManifest.xml file between your <application> tags: <meta-data android:name="com.google.android.geo.API_KEY" android:value="yourKeyHere"/>

  2. Then I got an issue with some java dynamite maps reference, adding the following line just before the line in step 2 resolved this error: <uses-library android:name="org.apache.http.legacy" android:required="false"/>

  3. Restart your emulator and it should prompt you to enable location services, accept and it should be good to go!

Let me know if you have any issues and I'll try to help you out!

dlcole commented 5 years ago

@tylerablake - I was excited to see your post and see if it would solve the problem for me. Alas, no luck. I did need to install play services, so here's what the SDK Tools looks like now:

Screen Shot 2019-03-08 at 10 20 44 PM

I already had the API key in my AndroidManifest.xml, but I added the line from your step 3:

<!-- See https://github.com/dapriett/nativescript-google-maps-sdk/issues/339 -->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/nativescript_google_maps_api_key" />

I noticed on the SDK Tools your emulator is back-level to what I'm using; not sure if that may be the issue or not. What does your app.gradle file look like? Did you add anything there for GooglePlayServices version?

tylerablake commented 5 years ago

Hi @dlcole, sorry it didn't work for you, I also added a new file before-plugins.gradle image

With the following contents project.ext.googlePlayServicesVersion = "15.0.1"

That is all I had to do to get it working for me.

Hope this helps!

dlcole commented 5 years ago

@tylerablake Very interesting! I tried specifying the googlePlayServicesVersion in app.gradle, and no luck. Then I commented that out and added the file before-plugins.gradle, as you suggested. Now it works! Thanks so much for your pointers; I don't think I would have ever figured this out on my own :-).

tylerablake commented 5 years ago

bitmoji No problem! Glad I could help! Happy NativeScripting!

Feedmeknowledge commented 5 years ago

@tylerablake Searched for a solution for a couple of days, only found your solution to work. Awesome. Thank you.

tylerablake commented 5 years ago

@Feedmeknowledge No problem!

himustofa commented 5 years ago

Where is project.ext.googlePlayServicesVersion = "15.0.1"

tylerablake commented 5 years ago

@himustofa I put that inside of the before-plugins.gadle file

himustofa commented 5 years ago

I have installed SDK Android 9.0, Android 7.1.1 and Android 6.0. Google Play services and else more. A few days ago update my Android Studio 3.4 (gradle 3.4.0). Now Google maps did not show in the emulator, the display is having trouble with google play services. please try again

But display google maps in real device!!! What is the problem, do you have any solutions?

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    package="com.zaaibo.passenger">

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

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

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-feature android:name="android.hardware.location.network" android:required="false" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:name="android.hardware.location.gps" android:required="false" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <dist:module dist:instant="true" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:name=".activity.MapsActivity"
            android:screenOrientation="portrait" />

        <uses-library android:name="org.apache.http.legacy" android:required="false"/>

        <!-- Start: Google Maps -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <!-- Start: fabric.io -->
        <meta-data
            android:name="io.fabric.ApiKey"
            android:value="48e94977edd45c608b874d3522a1d78045c05712" />

        <!-- Start: Firebase Cloud Messaging -->
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_radio_button_checked_black_24dp" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/colorAccent" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id" />
        <service
            android:name=".service.MyFirebaseMessagingService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <!-- Start: Android Image Cropper: optional (needed if default theme has no action bar) -->
        <activity
            android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
            android:theme="@style/Base.Theme.AppCompat" />

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

build.gradle(Project: Passenger)

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

build.gradle(Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.zaaibo.passenger"
        minSdkVersion 16
        targetSdkVersion 27
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'

    //Enable multidex for apps with over 64K methods
    implementation 'com.android.support:multidex:1.0.3'

    // Design, CardView
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'

    // GoogleMaps: maps, places, location for gps
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    implementation 'com.google.android.libraries.places:places:1.1.0'

    // GoogleMaps DirectionCallback
    implementation 'com.akexorcist:googledirectionlibrary:1.1.1'

    //Firebase libraries
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation 'com.google.firebase:firebase-storage:16.1.0'
    implementation 'com.google.firebase:firebase-auth:16.2.1'
    implementation 'com.google.firebase:firebase-messaging:17.6.0'
    implementation 'com.google.firebase:firebase-functions:16.3.0'

    //Fabric.io: crash reporting
    //implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
        transitive = true;
    }

    //GeoFire for Android/Java — Realtime location queries with Firebase
    implementation 'com.firebase:geofire-android:2.3.1'

    //Image circle in Navigation
    implementation 'de.hdodenhof:circleimageview:3.0.0'

    //Load Image Library
    implementation 'com.squareup.picasso:picasso:2.71828'

    //Android Image Cropper Library
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

apply plugin: 'com.google.gms.google-services'

apply plugin: 'io.fabric'
repositories {
    maven { url 'https://maven.fabric.io/public' }
}
tylerablake commented 5 years ago

@himustofa try this. I think the issue might be you need to re-enable Google Play services after your recent update of Android Studio for Google Maps to show on emulator

  1. Make sure Google Play services is enabled/installed inside of Android Studio Click SDK Manager in the top right of Android Studio to see the following: image

It should prompt for a download after you check the box and hit apply.

  1. Add the following line in your AndroidManifest.xml file between your <application> tags: <meta-data android:name="com.google.android.geo.API_KEY" android:value="yourKeyHere"/>
  2. Then I got an issue with some java dynamite maps reference, adding the following line just before the line in step 2 resolved this error: <uses-library android:name="org.apache.http.legacy" android:required="false"/>
  3. Restart your emulator and it should prompt you to enable location services, accept and it should be good to go!
NameYeoWool commented 5 years ago

In my case, change implementation 'com.google.android.gms:play-services-maps:16.1.0' implementation 'com.google.android.gms:play-services-places:16.1.0' to implementation 'com.google.android.gms:play-services-maps:16.0.0' implementation 'com.google.android.gms:play-services-places:16.0.0'

Log cat : google play servie out of date

so, downgrade library version

himustofa commented 5 years ago

Thanks for your important information.

guiguille commented 5 years ago

Did someone find a proper solution for this issue ?

After deactiving and reactiving the google play services, it works 🤷‍♂️

saechimdaeki commented 4 years ago

This error occurs after the computer suddenly shuts down by itself. It is working well on the cell phone.