Hello I have tired to write a simple google maps app. with v2.
However I'm having issues. The app work for a millisecond and then it crashes. Here is my code:
package com.stepi.maps; import com.stepi.maps.R; 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; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.MenuInflater; 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) { MenuInflater inflater= getMenuInflater(); inflater.inflate(R.menu.main, menu); return (super.onCreateOptionsMenu(menu)); } }
manifest code:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.stepi.maps" android:versionCode="1" android:versionName="1.0" > <uses-persmission android:name="com.stepi.maps.permission.MAPS_RECEIVE"/> <uses-persmission android:name="android.permission.INTERNET."/> <uses-persmission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-persmission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-persmission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-persmission android:name="android.permission.ACCESS_FINE_LOCATIONE"/> <permission android:name ="com.stepi.maps.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="17" /> <use-feature android:glEsVersion="0x00020000"/> <use-feature android:required="true" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.stepi.maps.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> <meta-data android:name="com.google.maps.v2.API_KEY" android:value="code here :) "/> </application> </manifest>
Thank you for your help