简体   繁体   中英

Google Maps app crash reporting

I've written this google maps app a while ago and I worked, but when I tried to run in on an Android device with Android version 6.0, it showed the Google map, but it didn't showed the current location of the user on the map and neither did an icon on the upper-right side to refresh the app and make the location more accurate if possible... When I run it on Android 5.1, it showed me even more errors and it didn't worked at all. please help :(

This is the AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.francydarkcool.maps">

<!-- Google Maps for Android v2 requires OpenGL ES v2 -->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality. 
-->
<permission
    android:name="com.example.francydarkcool.maps.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.francydarkcool.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

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

    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/xxxxx" />

    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Welcome">
        android:label="@string/Welcome">

    </activity>
</application>
</manifest>

This is the .java file:

package com.example.francydarkcool.maps;

import ...

public class MapsActivity extends FragmentActivity {

private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the MapFragment and get notified when the map is ready to be used.
    MapFragment mapFragment = (MapFragment) getFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
            mMap = googleMap;
            if (ActivityCompat.checkSelfPermission(MapsActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(MapsActivity.this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    ActivityCompat#requestPermissions
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for ActivityCompat#requestPermissions for more details.
                return;
            }
            mMap.setMyLocationEnabled(true);
            // Check if we were successful in obtaining the map.
            if (mMap != null) {
                setUpMap();
            }

        }
    });

    setUpMapIfNeeded();
}

protected void onResume() {
    super.onResume();
    setUpMapIfNeeded();
}


private void setUpMapIfNeeded() {
    //Do a null check to see if the map is not already instantiated
    if (mMap == null)
        //try to obtain the map from the MapFragment.
 //           mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMapAsync(onMapReady(mMap));

    {
        MapFragment mapFragment = (MapFragment) getFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap googleMap) {
                mMap = googleMap;
                if (ActivityCompat.checkSelfPermission(MapsActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(MapsActivity.this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                    // TODO: Consider calling
                    //    ActivityCompat#requestPermissions
                    // here to request the missing permissions, and then overriding
                    //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                    //                                          int[] grantResults)
                    // to handle the case where the user grants the permission. See the documentation
                    // for ActivityCompat#requestPermissions for more details.
                    return;
                }
                mMap.setMyLocationEnabled(true);
                // Check if we were successful in obtaining the map.
                if (mMap != null) {
                    setUpMap();
                }

            }
        });
    }
    //check if successful
    if (mMap != null) {
        setUpMap();
    }
}


private void setUpMap() {
    mMap.addMarker(new MarkerOptions().position(new LatLng(45.402850, 25.518595)).title("unu"));
    mMap.addMarker(new MarkerOptions().position(new LatLng(45.402856, 25.518608)).title("doi"));
    mMap.addMarker(new MarkerOptions().position(new LatLng(45.402834, 25.518772)).title("trei"));

    //Enable MyLocation Layer of Google Map
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

        return;
    }

    mMap.setMyLocationEnabled(true);

    //Get LocationManager object from System Service LOCATION_SERVICE
    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    //Create a criteria object to retrieve provider
    Criteria criteria = new Criteria();

    //Get the name of the best provider
    String provider = locationManager.getBestProvider(criteria, true);

    //Get current location
    Location myLocation = locationManager.getLastKnownLocation(provider);

    if(myLocation != null){
        double latitude = myLocation.getLatitude();
        double longitude = myLocation.getLongitude();
        }
    else
    {
        Location   getLastLocation = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
        double longitude = getLastLocation.getLongitude();
        double latitude = getLastLocation.getLatitude();
    }

    //set map type
    mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

    //Get latitude of the current location
    double latitude = myLocation.getLatitude();

    //Get longitude of the current location
    double longitude = myLocation.getLongitude();

    //Create a LatLng object for the current location
    LatLng latLng = new LatLng(latitude, longitude);

    //Show the current location in Google Maps
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

    //Zoom in GoogleMap
    mMap.animateCamera(CameraUpdateFactory.zoomTo(20));
}

}    

this is activity_maps.xml :

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.francydarkcool.maps.MapsActivity" />

And finally, these are the errors on running on Android 6.0:

E/FirebaseCrash: Failed to initialize crash reporting
             java.lang.RuntimeException: Missing an expected resource: 'R.string.google_api_key' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
                 at com.google.firebase.crash.internal.api.FirebaseCrashApiImpl.init(:com.google.android.gms.DynamiteModulesC:1089)
                 at bqs.onTransact(:com.google.android.gms.DynamiteModulesC:60)
                 at android.os.Binder.transact(Binder.java:387)
                 at com.google.firebase.crash.internal.zzd$zza$zza.zza(Unknown Source)
                 at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
                 at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
                 at java.lang.reflect.Method.invoke(Native Method)
                 at com.google.firebase.FirebaseApp.zza(Unknown Source)
                 at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                 at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                 at com.google.firebase.FirebaseApp.zzeh(Unknown Source)
                 at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
                 at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
                 at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
                 at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                 at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
                 at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
                 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
                 at android.app.ActivityThread.-wrap1(ActivityThread.java)
                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
                 at android.os.Handler.dispatchMessage(Handler.java:102)
                 at android.os.Looper.loop(Looper.java:148)
                 at android.app.ActivityThread.main(ActivityThread.java:5417)
                 at java.lang.reflect.Method.invoke(Native Method)
                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

And these ones are from running the same app on Android 5.1:

E/libprocessgroup: failed to make and chown /acct/uid_10058: Read-only file system
W/Zygote: createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
I/art: Not late-enabling -Xcheck:jni (already on)
W/art: Failed to find OatDexFile for DexFile /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_9-classes.dex ( canonical path /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_9-classes.dex) with checksum 0x96c9987f in OatFile /data/data/com.example.francydarkcool.maps/cache/slice-slice_9-classes.dex
W/art: Failed to find OatDexFile for DexFile /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_8-classes.dex ( canonical path /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_8-classes.dex) with checksum 0xfb6fb639 in OatFile /data/data/com.example.francydarkcool.maps/cache/slice-slice_8-classes.dex
W/art: Failed to find OatDexFile for DexFile /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_4-classes.dex ( canonical path /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_4-classes.dex) with checksum 0x91648fd3 in OatFile /data/data/com.example.francydarkcool.maps/cache/slice-slice_4-classes.dex
W/art: Failed to find OatDexFile for DexFile /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_2-classes.dex ( canonical path /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_2-classes.dex) with checksum 0x44af1327 in OatFile /data/data/com.example.francydarkcool.maps/cache/slice-slice_2-classes.dex
W/art: Failed to find OatDexFile for DexFile /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_0-classes.dex ( canonical path /data/data/com.example.francydarkcool.maps/files/instant-run/dex/slice-slice_0-classes.dex) with checksum 0x3993f84f in OatFile /data/data/com.example.francydarkcool.maps/cache/slice-slice_0-classes.dex
W/art: Verification of void com.google.firebase.FirebaseApp.<clinit>() took 273.032ms
W/art: Suspending all threads took: 16.600ms
I/art: Background sticky concurrent mark sweep GC freed 1202(325KB) AllocSpace objects, 11(244KB) LOS objects, 33% free, 1248KB/1872KB, paused 18.204ms total 30.940ms
A/FirebaseApp: Firebase API initialization failure.
               java.lang.reflect.InvocationTargetException
                   at java.lang.reflect.Method.invoke(Native Method)
                   at java.lang.reflect.Method.invoke(Method.java:372)
                   at com.google.firebase.FirebaseApp.zza(Unknown Source)
                   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                   at com.google.firebase.FirebaseApp.zzeh(Unknown Source)
                   at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
                   at android.content.ContentProvider.attachInfo(ContentProvider.java:1696)
                   at android.content.ContentProvider.attachInfo(ContentProvider.java:1671)
                   at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                   at enter code hereandroid.app.ActivityThread.installProvider(ActivityThread.java:4999)
                   at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
                   at android.app.ActivityThread.access$1500(ActivityThread.java:151)
                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                   at android.os.Handler.dispatchMessage(Handler.java:102)
                   at android.os.Looper.loop(Looper.java:135)
                   at android.app.ActivityThread.main(ActivityThread.java:5254)
                   at java.lang.reflect.Method.invoke(Native Method)
                   at java.lang.reflect.Method.invoke(Method.java:372)
                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                Caused by: java.lang.IllegalArgumentException: Given String is empty or null
                   at com.google.android.gms.common.internal.zzab.zzhs(Unknown Source)
                   at com.google.android.gms.internal.zzafl$zza$zza.<init>(Unknown Source)
                   at com.google.firebase.auth.FirebaseAuth.zza(Unknown Source)
                   at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
                   at com.google.android.gms.internal.zzafw.<init>(Unknown Source)
                   at com.google.firebase.auth.FirebaseAuth.zzc(Unknown Source)
                   at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)
                   at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
                   at java.lang.reflect.Method.invoke(Native Method) 
                   at java.lang.reflect.Method.invoke(Method.java:372) 
                   at com.google.firebase.FirebaseApp.zza(Unknown Source) 
                   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
                   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
                   at com.google.firebase.FirebaseApp.zzeh(Unknown Source) 
                   at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source) 
                   at android.content.ContentProvider.attachInfo(ContentProvider.java:1696) 
                   at android.content.ContentProvider.attachInfo(ContentProvider.java:1671) 
                   at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
                   at android.app.ActivityThread.installProvider(ActivityThread.java:4999) 
                   at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594) 
                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534) 
                   at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                   at android.os.Looper.loop(Looper.java:135) 
                   at android.app.ActivityThread.main(ActivityThread.java:5254) 
                   at java.lang.reflect.Method.invoke(Native Method) 
                   at java.lang.reflect.Method.invoke(Method.java:372) 
                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
D/ChimeraCfgMgr: Reading stored module config
I/DynamiteModule: Considering local module com.google.android.gms.flags:0 and remote module com.google.android.gms.flags:1
I/DynamiteModule: Selected remote version of com.google.android.gms.flags, version >= 1
I/art: Background sticky concurrent mark sweep GC freed 889(190KB) AllocSpace objects, 8(312KB) LOS objects, 12% free, 3MB/4MB, paused 5.892ms total 35.575ms
W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:3
I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 3
I/art: Background partial concurrent mark sweep GC freed 878(186KB) AllocSpace objects, 8(177KB) LOS objects, 39% free, 3MB/6MB, paused 6.096ms total 49.027ms
D/ChimeraFileApk: Primary ABI of requesting process is x86
D/ChimeraFileApk: Classloading successful. Optimized code found.
I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader com.google.android.chimera.container.internal.DelegateLastPathClassLoader[DexPathList[[zip file "/data/data/com.google.android.gms/app_chimera/m/00000002/DynamiteModulesC_GmsCore_prodlmp_alldpi_release.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]
I/DynamiteModule: Considering local module com.google.android.gms.flags:0 and remote module com.google.android.gms.flags:1
I/DynamiteModule: Selected remote version of com.google.android.gms.flags, version >= 1
E/FirebaseCrash: Failed to initialize crash reporting
                 java.lang.RuntimeException: Missing an expected resource: 'R.string.google_api_key' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
                     at com.google.firebase.crash.internal.api.FirebaseCrashApiImpl.init(:com.google.android.gms.DynamiteModulesC:1089)
                     at bqs.onTransact(:com.google.android.gms.DynamiteModulesC:60)
                     at android.os.Binder.transact(Binder.java:380)
                     at com.google.firebase.crash.internal.zzd$zza$zza.zza(Unknown Source)
                     at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
                     at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
                     at java.lang.reflect.Method.invoke(Native Method)
                     at java.lang.reflect.Method.invoke(Method.java:372)
                     at com.google.firebase.FirebaseApp.zza(Unknown Source)
                     at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                     at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                     at com.google.firebase.FirebaseApp.zzeh(Unknown Source)
                     at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
                     at android.content.ContentProvider.attachInfo(ContentProvider.java:1696)
                     at android.content.ContentProvider.attachInfo(ContentProvider.java:1671)
                     at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                     at android.app.ActivityThread.installProvider(ActivityThread.java:4999)
                     at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
                     at android.app.ActivityThread.access$1500(ActivityThread.java:151)
                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                     at android.os.Handler.dispatchMessage(Handler.java:102)
                     at android.os.Looper.loop(Looper.java:135)
                     at android.app.ActivityThread.main(ActivityThread.java:5254)
                     at java.lang.reflect.Method.invoke(Native Method)
                     at java.lang.reflect.Method.invoke(Method.java:372)
                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
I/FA: App measurement is starting up, version: 9256
I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
D/FA: Debug logging enabled
D/FA: AppMeasurement singleton hash: 181984923
V/FA: Collection enabled
V/FA: App package, google app id: com.example.francydarkcool.maps, angular-yen-123616
V/FA: Registered activity lifecycle callback
I/FirebaseInitProvider: FirebaseApp initialization successful
W/FA: Measurement Service called with unknown id version: angular-yen-123616
V/FA: Using measurement service
V/FA: Connecting to remote service
V/FA: onActivityCreated
W/art: Suspending all threads took: 8.612ms
I/art: Background sticky concurrent mark sweep GC freed 7219(1116KB) AllocSpace objects, 29(628KB) LOS objects, 27% free, 4MB/6MB, paused 11.350ms total 48.117ms
I/zzae: Making Creator dynamically
D/ChimeraFileApk: Primary ABI of requesting process is x86
D/ChimeraFileApk: Classloading successful. Optimized code found.
I/Google Maps Android API: Google Play services client version: 9256000
I/Google Maps Android API: Google Play services package version: 9256270
I/c: Token loaded from file. Expires in: 30813655 ms.
I/c: Scheduling next attempt in 30513 seconds.
V/FA: Activity resumed, time: 125857
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true

                  [ 07-24 12:04:31.463  2501: 2501 D/         ]
                  HostConnection::get() New Host Connection established 0xa282ed00, tid 2501
D/Atlas: Validating map...
D/AndroidRuntime: Shutting down VM


                  --------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.francydarkcool.maps, PID: 2501
                  java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLongitude()' on a null object reference
                      at com.example.francydarkcool.maps.MapsActivity.setUpMap(MapsActivity.java:149)
                      at com.example.francydarkcool.maps.MapsActivity.access$100(MapsActivity.java:18)
                      at com.example.francydarkcool.maps.MapsActivity$1.onMapReady(MapsActivity.java:46)
                      at com.google.android.gms.maps.MapFragment$zza$1.zza(Unknown Source)
                      at com.google.android.gms.maps.internal.zzp$zza.onTransact(Unknown Source)
                      at android.os.Binder.transact(Binder.java:380)
                      at xk.a(:com.google.android.gms.DynamiteModulesB:82)
                      at maps.af.t$5.run(Unknown Source)
                      at android.os.Handler.handleCallback(Handler.java:739)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:135)
                      at android.app.ActivityThread.main(ActivityThread.java:5254)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:372)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:1
I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 1
D/ChimeraFileApk: Primary ABI of requesting process is x86
D/ChimeraFileApk: Classloading successful. Optimized code found.
D/GoogleCertificates: com.google.android.gms.googlecertificates module is loaded
D/GoogleCertificatesImpl: Fetched 318 Google certificates
I/Process: Sending signal. PID: 2501 SIG: 9
Application terminated.

And this is the gradle.build file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
    applicationId "com.example.francydarkcool.maps"
    minSdkVersion 16
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.android.gms:play-services-maps:9.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:24.1.0'
}

Do you have google_maps_api.xml file?

You need to register for a Google Maps API key. For more information as to what else is needed to use Google services. Please see the following documentation under Step 4.

https://developers.google.com/maps/documentation/android-api/start

Step 4. Get a Google Maps API key

Your application needs an API key to access the Google Maps servers. The type of key you need is a Key for Android applications. The key is free. You can use it with any of your applications that call the Google Maps Android API, and it supports an unlimited number of users.

Choose one of the following ways to get your API key:

The fast, easy way: Use the link provided in the google_maps_api.xml file that Android Studio created for you:

Copy the link provided in the google_maps_api.xml file and paste it into your browser. The link takes you to the Google API Console and supplies information via URL parameters, thus reducing the manual input required from you. Follow the instructions to create a new project on the console or select an existing project. Create an Android API key for your console project. Copy the resulting API key, go back to Android Studio, and paste the API key into the element in the google_maps_api.xml file. A slightly less fast way: Use the credentials provided in the google_maps_api.xml file that Android Studio created for you:

Copy the credentials provided in the google_maps_api.xml file. Go to the Google API Console in your browser. Use the copied credentials to add your app to an existing API key or to create a new API key. For more details, see the complete process. The full process for getting an API key: If neither of the above options works for your situation, follow the complete process.

Specifically, you can fix this issue by downloading and copying the google-services.json file for your Android app by following the steps below:

Select your app/project name and Android packagename from this link and click Continue to Choose and configure services. Click Continue to Generate Configuration files. Download google-services.json and copy the file to the app/ or mobile/ module directory in your Android project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM