2016-07-19 4 views
0

Ich habe diese Google Maps App vor einer Weile geschrieben und ich arbeitete, aber als ich versuchte, auf einem Android-Gerät mit Android Version 6.0 zu laufen, zeigte es die Google-Karte, aber es nicht zeigte den aktuellen Standort des Benutzers auf der Karte und auch nicht ein Symbol auf der oberen rechten Seite, um die App zu aktualisieren und den Standort genauer zu machen, wenn möglich ... Wenn ich es unter Android 5.1 ausführte, zeigte es mir noch mehr Fehler und es hat überhaupt nicht funktioniert. bitte helfen :(Google Maps App Absturzberichterstattung

Dies ist die AndroidManifest.xml Datei:

<?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> 

Dies ist die .java-Datei:

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

}  

das ist 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" /> 

Und schließlich, Dies sind die Fehler beim Ausführen von 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) 

Und diese sind, die von der gleichen App auf Android läuft 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. 

Und das ist die gradle.build Datei:

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

Überprüfen Sie die akzeptierte Antwort [hier] (http://stackoverflow.com/questions/34365369/googleservice-failed-to-initialize), ich denke, dass die Idee hier in Ihrem Fall hilfreich sein wird. – KENdi

Antwort

0

Haben Sie google_maps_api.xml Datei haben?

Sie müssen sich für einen Google Maps-API-Schlüssel registrieren. Weitere Informationen dazu, was sonst noch benötigt wird, um Google-Dienste zu nutzen Bitte beachten Sie die folgende Dokumentation unter Schritt 4.

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

Schritt 4. Holen Sie sich ein Google Maps-API-Schlüssel

Ihre Anwendung benötigt einen API-Schlüssel, die Google Maps-Server zugreifen zu können. Die Art des Schlüssels, den Sie benötigen, ist ein Schlüssel für Android-Anwendungen. Der Schlüssel ist frei. Sie können es mit jeder Ihrer Anwendungen verwenden, die die Google Maps Android API aufrufen, und es unterstützt eine unbegrenzte Anzahl von Benutzern.

Wählen Sie eine der folgenden Möglichkeiten, um Ihre API-Schlüssel zu erhalten:

Die schnelle und einfache Möglichkeit: Mit diesem Link kann in der google_maps_api.xml Datei zur Verfügung gestellt, die Android Studio für Sie erstellt:

Kopieren Sie den Link in der Datei google_maps_api.xml bereitgestellt und fügen Sie sie in Ihren Browser ein. Der Link führt Sie zur Google API-Konsole und liefert Informationen über URL-Parameter, wodurch die manuelle Eingabe für Sie reduziert wird. Befolgen Sie die Anweisungen, um ein neues Projekt auf der Konsole zu erstellen oder wählen Sie ein vorhandenes Projekt aus. Erstellen Sie einen Android-API-Schlüssel für Ihr Konsolenprojekt. Kopieren Sie den resultierenden API-Schlüssel, gehen Sie zurück zu Android Studio und fügen Sie den API-Schlüssel in das Element in der Datei google_maps_api.xml ein. Ein etwas weniger schneller Weg: Verwenden Sie die in der Datei google_maps_api.xml von Android Studio bereitgestellten Anmeldeinformationen:

Kopieren Sie die in der Datei google_maps_api.xml bereitgestellten Anmeldeinformationen. Rufen Sie in Ihrem Browser die Google API-Konsole auf. Verwenden Sie die kopierten Anmeldeinformationen, um Ihre App einem vorhandenen API-Schlüssel hinzuzufügen oder einen neuen API-Schlüssel zu erstellen.Weitere Informationen finden Sie im vollständigen Prozess. Der vollständige Prozess zum Abrufen eines API-Schlüssels: Wenn keine der obigen Optionen für Ihre Situation geeignet ist, folgen Sie dem vollständigen Prozess.

Insbesondere können Sie dieses Problem beheben, indem Sie das Herunterladen und Kopieren der Google-services.json Datei für Ihre Android-App, indem Sie die folgenden Schritte:

Wählen Sie Ihre app/Projektnamen und Android Paket über diesen Link und klicken Sie auf Weiter zu Auswählen und Konfigurieren von Diensten. Klicken Sie auf Weiter, um Konfigurationsdateien zu generieren. Laden Sie google-services.json herunter und kopieren Sie die Datei in das Verzeichnis app/or mobile/module in Ihrem Android-Projekt.

+0

ja, ich habe. Ich habe vergessen, dies zu erwähnen – rocko

+0

Ich habe sogar versucht, den API-Schlüssel zu ändern ... immer noch alle diese Fehler ... – rocko

+0

Ich denke, das Problem ist mit Ihrer build.gradle (Modul-App) -Datei. Könntest du das posten? – hello404