2017-06-23 13 views
1

この質問は何度か提起されていますが、私はすべてWAを試してみて助けませんでした。私のアプリはデバッグモードで正常に動作していますが、署名付きコピーを生成した後GoogleマップはGoogleロゴの空白の画面を表示します。公開後にGoogleマップが空白になっています

enter image description here

私はパッケージとSHA1が正しく追加されていることを確認しました、署名済みAPKを生成する際に使用される私のいるkeystoreFileから得られSHA1を使用して、それを制限する、新しいAPIキーを生成しようとした、私はこれらすべての工程を数回繰り返したが、問題は同じです! は、ここに私のコードです:

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    View rootView = inflater.inflate(R.layout.activity_maps, container, false); 

    mMapView = (MapView) rootView.findViewById(R.id.map); 
    mMapView.onCreate(savedInstanceState); 

    mMapView.onResume(); // needed to get the map to display immediately 

    try { 
     MapsInitializer.initialize(getActivity().getApplicationContext()); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 
     checkLocationPermission(); 
    } 
    // Obtain the SupportMapFragment and get notified when the map is ready to be used. 

    mMapView.getMapAsync(new OnMapReadyCallback() { 
     @Override 


     public void onMapReady(GoogleMap googleMap) { 
      mMap = googleMap; 
      mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); 
      googleMap.setTrafficEnabled(true); 

      //Initialize Google Play Services 
      if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 
       if (ContextCompat.checkSelfPermission(getContext(), 
         Manifest.permission.ACCESS_FINE_LOCATION) 
         == PackageManager.PERMISSION_GRANTED) { 
        buildGoogleApiClient(); 
        mMap.setMyLocationEnabled(true); 
       } 
      } else { 
       buildGoogleApiClient(); 
       mMap.setMyLocationEnabled(true); 
      } 
     } 
    }); 


    final LocationManager manager = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE); 

    if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { 
     buildAlertMessageNoGps(); 
    } 
    return rootView; 
} 

private void buildAlertMessageNoGps() { 
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 
    builder.setMessage("Your GPS seems to be disabled, do you want to enable it?") 
      .setCancelable(false) 
      .setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
       public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) { 
        startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); 
       } 
      }) 
      .setNegativeButton("No", new DialogInterface.OnClickListener() { 
       public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) { 
        dialog.cancel(); 
       } 
      }); 
    final AlertDialog alert = builder.create(); 
    alert.show(); 
} 
@Override 
public void onResume() { 
    super.onResume(); 
    mMapView.onResume(); 
} 

@Override 
public void onPause() { 
    super.onPause(); 
    mMapView.onPause(); 
} 

@Override 
public void onDestroy() { 
    super.onDestroy(); 
    mMapView.onDestroy(); 
} 

@Override 
public void onLowMemory() { 
    super.onLowMemory(); 
    mMapView.onLowMemory(); 
} 

protected synchronized void buildGoogleApiClient() { 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 
     mGoogleApiClient = new GoogleApiClient.Builder(getContext()) 
       .addConnectionCallbacks(this) 
       .addOnConnectionFailedListener(this) 
       .addApi(LocationServices.API) 
       .build(); 
    } 
    mGoogleApiClient.connect(); 
} 

@Override 
public void onConnected(Bundle bundle) { 

    mLocationRequest = new LocationRequest(); 
    mLocationRequest.setInterval(1000); 
    mLocationRequest.setFastestInterval(1000); 
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); 
    if (ContextCompat.checkSelfPermission(getActivity(), 
      Manifest.permission.ACCESS_FINE_LOCATION) 
      == PackageManager.PERMISSION_GRANTED) { 
     LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this); 
    } 

} 

@Override 
public void onConnectionSuspended(int i) { 

} 

そして、ここに一部現れる可能性がある。

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

を、これはレイアウトです:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 

android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<com.google.android.gms.maps.MapView 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

</RelativeLayout> 
+0

リリースビルドにProGuardを使用していますか?その場合は、Googleマップの関連設定を確認してください。 https://github.com/googlemaps/android-samples/blob/master/ApiDemos/app/proguard-rules.pro –

答えて

0

は私が問題を発見しました。私のAPIはリリースXMLファイルに存在しませんでした。

関連する問題