3

I'm creating sample application to use Google Maps Android API v2.

I tried on Samsung Galaxy Ace GT-S5830i, but instead of Map, I'm seeing

enter image description here

And logcat is

 Signature not valid.  Found: 
 MIIDDTCCAfWgAwIBAgIEEhX+gTANBgkqhkiG9w0BAQsFADA3MQswCQYDVQQGEwJVUzEQMA4GA1UE
 ChMHQW5kcm9pZDEWMBQGA1UEAxMNQW5kcm9pZCBEZWJ1ZzAeFw0xMzAyMjUxMTEwNDRaFw00MzAy
 MTgxMTEwNDRaMDcxCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdBbmRyb2lkMRYwFAYDVQQDEw1BbmRy
 b2lkIERlYnVnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApqChoDnHsDfsxa7n2Kv9
 2av0G0tm+kS1uP4T6fA8cO6jB3qB5EHFR6+5UO+k4laHW2WzOJbyhhtFE5eOTS4Zt5qo4FX/hsc/
 Zi7dDX/Y13b+4qajhLoGYqVjM00eQc2qF58TTnbQ3lTERxaofYL2qI3j2KcVODFMksinL9lt3RTD
 V3MXy7KDLcuSvoVZxXn1L0O9rkTbZicmleK4wLDzI+lTpuXngAuQ4MBH1wEWwqMhJg6/J06t5axU
 ea2UVv7ZtYg8KPMEiQEApCbdAHtQsmqcsEQZtJAqFtj7KEQ7wTSgnpDRix4N5C9QlwUtKSlOCIlk
 ueUPVBypKf/SWIgF6QIDAQABoyEwHzAdBgNVHQ4EFgQURyMuspjlLaDj8LhEb5UyYqQgWQYwDQYJ
 KoZIhvcNAQELBQADggEBAA9IXLEAQTD+VEt9l8JQDEOFv8WqIdQisvmJCfJjN98faarvf6RRA+v3
 HF2VFlZPaUu/HBeOH8MI7u+gNuRtZGYWn1eC/qfP0W31MQoNaN4ocsF+tL9INzpd89/u6Ya5Kove
 r0E0tpJFBgdtDPYcPBjQ6tYAqmhnmPIJftGHLNQbil4ocK/PkqgxGlwQN7WrCNjDewb0twz7hZBx
 Ig4OsnfdgPTYGlR+LyTzUd9/KyqaLHivRAI+y/xGDz6lOfGH7bDOPi/hDm0bkhC1y1J7L9+FiGWb
 dmi+Co9Jlf1f3vyTtD7kr3h0K0C3MsNWtybVqmVvgImoLt/lPbjNJahVrds=
 Google Play services signature invalid.
 Can't open keycharmap file
 Error loading keycharmap file
 Using default keymap

My manifest code

<?xml version="1.0" encoding="utf-8"?>

<permission
    android:name="com.example.testmap.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.testmap.permission.MAPS_RECEIVE" />

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<permission
    android:name="com.example.testmap.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyDTsWrO0j24sbp4E5qhoHhd6nyOQM5lErc" />

    <activity
        android:name="com.example.testmap.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

my xml file code

<?xml version="1.0" encoding="utf-8"?>

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />

My activity code

package com.example.testmap;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.final_main);

    GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    //map.getMinZoomLevel();
}
}

And clicking on ok button gives force close with Logcat

 FATAL EXCEPTION: main
 java.lang.NullPointerException
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1374)
at android.app.Activity.startActivityForResult(Activity.java:2827)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
at android.app.Activity.startActivity(Activity.java:2933)
at com.google.android.gms.internal.e$2.onClick(Unknown Source)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)

Also when I UN-comment last line map.getMinZoomLevel(); , I get null pointer exception on the line.

android developer
  • 491
  • 3
  • 7
  • 16

2 Answers2

0

Check if you have enabled offline work for gradle: Goto File > Settings > Gradle

Deselect Offline Work if its checked.

Then confirm if you have latest version of google services mentioned as dependencies in project level build.gradle: classpath 'com.google.gms:google-services:2.1.0'

You can find latest version here: https://jcenter.bintray.com/com/android/tools/build/gradle/

Clean and build the project after gradle sync completes. ouThese steps solved a similar issue I'd with Google Maps and also solved the first error you mentioned Signature Not Valid

If your device runs on Android M, you may want to verify your code for location access following this answer.

Community
  • 1
  • 1
Ruturaj Patil
  • 608
  • 1
  • 10
  • 25
0

I was also getting same exception and I fixed it.

Note: I am working on google analytics and was getting this exception. But my app was not crashing I was getting this in Logs. you can also try this solution.

add this in project level gradle file.

classpath 'com.google.gms:google-services:2.1.0'

and this one for module level gradle file.

compile 'com.google.android.gms:play-services:8.4.0'

and move `below plugin at the end of file (at last line) of module level gradle file.

apply plugin: 'com.google.gms.google-services'
Developine
  • 12,483
  • 8
  • 38
  • 42