El asunto es el siguiente, termine de hacer mi aplicación en la IDE de Android Studio, Al emular la app en el emulador o en un dispositivo físico va todo bien, el problema surge cuando genero la APK.
Ahora explico: Google maps se ve sin problemas al emular, no así al generar la APK por medio de Android Studio, esta se ve como si no reconociera la api-key osea no se refleja el mapa y no entiendo por que... Cabe recalcar que ya utilice "multiDexEnabled true", también genere la huella SHA-1 y el mapa sigue sin funcionar.
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=3A:64:19:43:62:19:28:63:12:A0:F2:39:79:F3:9A:05:1F:44:2F:51%3Bixtapa.com.mx.ixtapazihua
You can also add your credentials to an existing key, using this line:
3A:64:19:43:62:19:28:63:12:A0:F2:39:79:F3:9A:05:1F:44:2F:51;ixtapa.com.mx.ixtapazihua
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">
AIzaSyDAgFUrcH2olG29IUClfIrSgqH4-wZ0AL8
</string>
Clase del Mapa
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
String lat = "";
String lon = "";
String Name= "";
String Address="";
int latI;
int lonI;
Double latD2, lonD2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Otain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Intent i = getIntent();
Bundle extra = i.getExtras();
if (extra != null) {
lat = (String) extra.get("Lat");
lon = (String) extra.get("Lng");
Name = (String) extra.get("Name");
Address = (String) extra.get("Address");
}
//Toast.makeText(this, "Se recibieron los valores", Toast.LENGTH_SHORT).show();
//Toast.makeText(this, lat + lon, Toast.LENGTH_SHORT).show();
else {
Toast.makeText(this, "No se reciben valores", Toast.LENGTH_LONG).show();
}
latD2 = Double.parseDouble(lat);
lonD2 = Double.parseDouble(lon);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng Hotels = new LatLng(latD2, lonD2);
mMap.addMarker(new MarkerOptions().position(Hotels).title(Name)
.snippet(Address)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN)));
mMap.moveCamera(CameraUpdateFactory.newLatLng(Hotels));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(latD2, lonD2), 12));
mMap.getUiSettings().setZoomControlsEnabled(true);
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) {
// 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);
}
}