4
respostas

Não carrega mapa

Não esta carregando o mapa.

public class AguardandoValidacaoATM extends AppCompatActivity {

    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aguardando_validacao_atm);

        Button botao_mapa = (Button) findViewById(R.id.bt_validacao_mapa);
        botao_mapa.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent vaiParaMapa = new Intent(AguardandoValidacaoATM.this, MapaActivity.class);
                Toast.makeText(AguardandoValidacaoATM.this, "Localize agencia mais próxima", Toast.LENGTH_SHORT).show();
                startActivity(vaiParaMapa);
            }
        });
    }
}

Manifest.xml

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

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

        <activity android:name=".ui.MapaActivity"></activity>
    </application>

MapaActivity

public class MapaActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mapa);

        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction tx = manager.beginTransaction();
        tx.replace(R.id.frame_mapa, new SupportMapFragment());
        tx.commit();

google_maps_api.xml

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">minhaKey</string>
4 respostas

Oi Adriano,

aparece algo no LogCat? Coloque aqui pra gente o que acontece quando chega a executar esse Fragment.

Abraços

Segue Logcat

12-26 09:26:50.212 16497-16497/br.com.MEU_PACOTE I/Timeline: Timeline: Activity_launch_request id:br.com.MEU_PACOTE time:104047968
12-26 09:26:50.338 16497-16497/br.com.MEU_PACOTE I/zzbz: Making Creator dynamically
12-26 09:26:50.353 16497-16497/br.com.MEU_PACOTE I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:18
12-26 09:26:50.353 16497-16497/br.com.MEU_PACOTE I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 18
12-26 09:26:50.386 16497-16497/br.com.MEU_PACOTE W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/0000000c/n/armeabi
12-26 09:26:50.443 16497-16497/br.com.MEU_PACOTE I/Google Maps Android API: Google Play services client version: 11910000
12-26 09:26:50.451 16497-16497/br.com.MEU_PACOTE I/Google Maps Android API: Google Play services package version: 11951436
12-26 09:26:50.679 16497-16505/br.com.MEU_PACOTE I/System: FinalizerDaemon: finalize objects = 74
12-26 09:26:50.880 16497-16497/br.com.MEU_PACOTE I/Choreographer: Skipped 34 frames!  The application may be doing too much work on its main thread.
12-26 09:26:50.903 16497-16563/br.com.MEU_PACOTE W/libEGL: [ANDROID_RECORDABLE] format: 1
12-26 09:26:51.426 16497-20960/br.com.MEU_PACOTE E/Google Maps Android API: Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
12-26 09:26:51.428 16497-20960/br.com.MEU_PACOTE 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: AIzaSyAi5_5lUzccOS9Iu6fwvJ10yjeavLVRsI0
                                                                                                 Android Application (<cert_fingerprint>;<package_name>): 90:99:50:6B:9F:20:26:90:61:F0:8A:1C:64:8E:AD:BD:8C:43:3D:2B;br.com.MEU_PACOTE
12-26 09:26:52.876 16497-20958/br.com.MEU_PACOTE W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
12-26 09:26:52.885 16497-20958/br.com.MEU_PACOTE I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
12-26 09:26:52.885 16497-20958/br.com.MEU_PACOTE I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 4
12-26 09:26:52.889 16497-20958/br.com.MEU_PACOTE W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/0000000a/n/armeabi-v7a
12-26 09:26:52.889 16497-20958/br.com.MEU_PACOTE W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/0000000a/n/armeabi
12-26 09:26:55.929 16497-16497/br.com.MEU_PACOTE W/System.err: java.io.IOException: grpc failed
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at br.com.MEU_PACOTE.ui.fragment.MapaFragment.pegaCoordenadas(MapaFragment.java:42)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at br.com.MEU_PACOTE.ui.fragment.MapaFragment.onMapReady(MapaFragment.java:31)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at com.google.android.gms.maps.zzak.zza(Unknown Source)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at com.google.android.gms.maps.internal.zzaq.onTransact(Unknown Source)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at android.os.Binder.transact(Binder.java:392)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at er.b(:com.google.android.gms.DynamiteModulesB@11951436:20)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at com.google.android.gms.maps.internal.bf.a(:com.google.android.gms.DynamiteModulesB@11951436:5)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at com.google.maps.api.android.lib6.impl.bc.run(:com.google.android.gms.DynamiteModulesB@11951436:5)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at android.os.Handler.handleCallback(Handler.java:815)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:104)
12-26 09:26:55.932 16497-16497/br.com.MEU_PACOTE W/System.err:     at android.os.Looper.loop(Looper.java:207)

Oi Adriano,

pelo que pude notar a autorização falhou. Veja se vc tem as permissões de mapas corretamente setadas e principalmente se lá na sua conta de desenvolvedor da Google a sua Api Key relacionada a mapas V2 está habilitada.

Uma coisa que percebi eh que o LogCat acusou que vc teria uma aplicação com o package MEU_PACOTE.

Durante a geração da api key vc trocou pelo pacote da sua aplicação? Me parece que lá no formulário vc não trocou para o identificador do seu app(que eh o pacote).

Confirma por favor isso. Exceto se sua app tenha esse pacote mesmo :)

Abraços