Salve.
Stavo cercando di poter far aprire una mappa tramite il Navigation Drawer.
Per quanto riguarda la creazione dei vari Fragments, tutto apposto, infatti tramite il Navigation Drawer, potevo aprire tutte le varie cose che mi portavano nell'apposito fragment.
Premetto che ho guardato numerose guide sul come aggiungere un map fragment.
Non ho fatto altro che andare nel fragment della mappa che si trova in "layout", e scrivere all'interno del file .xml:
codice:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
tools:context="it.prova.MapFragment">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
mentre, nel file .java che reindirizza al fragment della mappa, ho scritto:
codice:
package it.prova;
import ...
public class MapFragment extends Fragment{
public MapFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_map, container, false);
}
}
Sono sicuro che l'errore, si trova all'interno di quest'ultimo file, anche se non so quale sia.
Come ultima cosa, ho creato un file in values chiamato "google_maps_api", all'interno del quale ho scritto:
codice:
<resources>
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">(La mia API key scritta correttamente)</string>
</resources>
L'errore che mi da il compilatore è il seguente:
17062-17208/it.prova E/b: Authentication failed on the server.
17062-17208/it.prova E/Google*Maps*Android*API: Authorization failure. Please see https://developers.google.com/maps/d...roid-api/start for how to correctly set up the map.
17062-17208/it.prova E/Google*Maps*Android*API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: La mia API key (si è inserita correttamente)
Android Application (<cert_fingerprint>;<package_name>): 6E:F7:62:8E:540:69:E9:6B:CF:0C:F1:1B:29:7F:F6:F0:13:02:AB;it.pro va