Android: Wstawianie map z google play service

0

Witam. mam problem z wstawieniem map google. robilem wszystko wedlug tutoriali i aplikacja sie wlacza ale mapa sie nie wczytuje, mam tylko opcje odleglosci "+" i "-" w prawym dolnym rogu i biale tlo.

MainActivity:

 
package a.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

public class MainActivity extends Activity {
  static final LatLng HAMBURG = new LatLng(53.558, 9.927);
  static final LatLng KIEL = new LatLng(53.551, 9.993);
  private GoogleMap map;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
        .getMap();
    Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
        .title("Hamburg"));
    Marker kiel = map.addMarker(new MarkerOptions()
        .position(KIEL)
        .title("Kiel")
        .snippet("Kiel is cool")
        .icon(BitmapDescriptorFactory
            .fromResource(R.drawable.ic_launcher)));
 
    // Move the camera instantly to hamburg with a zoom of 15.
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));

    // Zoom in, animating the camera.
    map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

}

activity_main

 
<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="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />
    
    <fragment 
          android:id="@+id/map"
          android:name="com.google.android.gms.maps.MapFragment"
          android:layout_below="@+id/header"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/>

</RelativeLayout>

Manifest:

 
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="a.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="17" />

    <permission
        android:name="a.test.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="a.test.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />

        <activity
            android:name="a.test.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="a.test.Sddddd"
            android:label="@string/title_activity_sddddd" >
        </activity>
    </application>

</manifest>

logcat:

06-16 11:49:57.506: D/dalvikvm(1049): GC_CONCURRENT freed 263K, 14% free 2552K/2960K, paused 16ms+30ms, total 107ms
06-16 11:49:57.776: E/Google Maps Android API(1049): Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above
06-16 11:49:57.977: D/dalvikvm(1049): GC_CONCURRENT freed 237K, 13% free 2723K/3104K, paused 69ms+88ms, total 189ms
06-16 11:49:58.327: D/dalvikvm(1049): GC_CONCURRENT freed 207K, 11% free 2972K/3324K, paused 72ms+85ms, total 208ms
06-16 11:49:58.587: D/libEGL(1049): Emulator without GPU support detected. Fallback to software renderer.
06-16 11:49:58.587: D/libEGL(1049): loaded /system/lib/egl/libGLES_android.so
06-16 11:49:58.607: I/Choreographer(1049): Skipped 252 frames! The application may be doing too much work on its main thread.
06-16 11:49:58.657: D/gralloc_goldfish(1049): Emulator without GPU emulation detected.
06-16 11:49:58.757: I/Choreographer(1049): Skipped 68 frames! The application may be doing too much work on its main thread.
06-16 11:49:59.026: D/dalvikvm(1049): GC_CONCURRENT freed 286K, 13% free 3082K/3516K, paused 10ms+4ms, total 56ms
06-16 11:49:59.026: D/dalvikvm(1049): WAIT_FOR_CONCURRENT_GC blocked 47ms
06-16 11:49:59.086: D/dalvikvm(1049): GC_FOR_ALLOC freed 323K, 17% free 3064K/3668K, paused 32ms, total 36ms
06-16 11:49:59.146: D/dalvikvm(1049): GC_FOR_ALLOC freed 324K, 17% free 3065K/3668K, paused 23ms, total 27ms
06-16 11:49:59.196: D/dalvikvm(1049): GC_FOR_ALLOC freed 304K, 17% free 3066K/3668K, paused 23ms, total 25ms
06-16 11:49:59.276: D/dalvikvm(1049): GC_CONCURRENT freed 382K, 18% free 3070K/3704K, paused 6ms+3ms, total 30ms
06-16 11:49:59.276: D/dalvikvm(1049): WAIT_FOR_CONCURRENT_GC blocked 25ms
06-16 11:52:26.154: I/Choreographer(1049): Skipped 100 frames! The application may be doing too much work on its main thread.
06-16 11:54:02.624: I/Choreographer(1049): Skipped 42 frames! The application may be doing too much work on its main thread.
06-16 11:55:41.844: I/Choreographer(1049): Skipped 120 frames! The application may be doing too much work on its main thread.
06-16 11:55:42.514: I/Choreographer(1049): Skipped 116 frames! The application may be doing too much work on its main thread.
06-16 11:56:38.694: I/Choreographer(1049): Skipped 101 frames! The application may be doing too much work on its main thread.
06-16 11:56:39.744: I/Choreographer(1049): Skipped 97 frames! The application may be doing too much work on its main thread.
06-16 11:56:40.024: I/Choreographer(1049): Skipped 119 frames! The application may be doing too much work on its main thread.
06-16 11:56:41.594: I/Choreographer(1049): Skipped 122 frames! The application may be doing too much work on its main thread.
06-16 11:56:41.824: I/Choreographer(1049): Skipped 88 frames! The application may be doing too much work on its main thread.
06-16 11:56:42.094: I/Choreographer(1049): Skipped 106 frames! The application may be doing too much work on its main thread.
06-16 11:56:42.294: I/Choreographer(1049): Skipped 118 frames! The application may be doing too much work on its main thread.
06-16 11:56:42.394: I/Choreographer(1049): Skipped 107 frames! The application may be doing too much work on its main thread.

0

Nie masz poprawnego klucza w manifeście :

<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />

Tu gdzie są x-y powinien być klucz, który musisz sam wygenerować (za pomocą narzędzia keytool), osobno dla wersji debug i release. Jest to opisane w wielu tematach na stack overflow. Trzeba go stworzyć w google api console. WAŻNA UWAGA: nie pomyl google maps android v2 android z google maps android v2.

0

hehe wiem:) po prostu nie chcialem pokazywac swojego klucza;p

ogolnie problem rozwiazany. odpalalem to na emulatorze ktory nie obsluguje opengl es 2.0. wystarczy odpalic na telefonie i dziala:)

edit:
do zamkniecia

0

Na tym forum nie zamyka się tematów, ale dzięki za odpowiedź. Nie wiedziałem, że na emulatorze nie działają.

1 użytkowników online, w tym zalogowanych: 0, gości: 1