My android google Map v2 application crashes - android

i'm making an android map application , using goggle maps v2 , alla went ok until i run the application , it crashs . thes are my files :
MainActivity.java
package com.geo.app;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
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.SupportMapFragment;
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 FragmentActivity {
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=((SupportMapFragment)getSupportFragmentManager().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);
}
}
activity_main.xml
<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"
tools:context=".MainActivity" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.geo.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="18" />
<permission
android:name="com.geo.app.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<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"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.geo.app.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.android.maps.v2.API_KEY"
android:value="AIzaSyB0MLq8L4YCA9GC05iD1V7OYfqlkUa0lhA" />
</application>
</manifest>
The application crashed , and i have this on my LogCat
04-10 10:59:02.545 11918-11918/? D/AndroidRuntime﹕ >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
04-10 10:59:02.545 11918-11918/? D/AndroidRuntime﹕ CheckJNI is OFF
04-10 10:59:02.725 11918-11918/? D/AndroidRuntime﹕ --- registering native functions ---
04-10 10:59:03.495 104-205/? I/ActivityManager﹕ Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.geo.app/.MainActivity }
04-10 10:59:03.605 11918-11918/? D/AndroidRuntime﹕ Shutting down VM
04-10 10:59:03.605 11918-11923/? D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
04-10 10:59:03.625 11918-11926/? I/AndroidRuntime﹕ NOTE: attach of thread 'Binder Thread #3' failed
04-10 10:59:03.675 5325-5325/? D/PackageAddedReceiver﹕ package added com.geo.app
04-10 10:59:03.695 104-107/? I/ActivityManager﹕ Start proc com.geo.app for activity com.geo.app/.MainActivity: pid=11928 uid=10082 gids={3003, 1015}
04-10 10:59:04.175 182-182/? D/dalvikvm﹕ GC_EXPLICIT freed 5596 objects / 283440 bytes in 5136ms
04-10 10:59:04.275 3332-11910/? D/RegisterService﹕ insert plugin size 1
04-10 10:59:04.335 104-243/? D/Sensors﹕ open_akm, fd=148
04-10 10:59:04.625 77-77/? D/AK8973﹕ Compass Start
04-10 10:59:04.745 11928-11928/com.geo.app W/dalvikvm﹕ VFY: unable to resolve static field 3704 (MapAttrs) in Lcom/google/android/gms/R$styleable;
04-10 10:59:04.745 11928-11928/com.geo.app D/dalvikvm﹕ VFY: replacing opcode 0x62 at 0x000e
04-10 10:59:04.745 11928-11928/com.geo.app D/dalvikvm﹕ VFY: dead code 0x0010-00ae in Lcom/google/android/gms/maps/GoogleMapOptions;.createFromAttributes (Landroid/content/Context;Landroid/util/AttributeSet;)Lcom/google/android/gms/maps/GoogleMapOptions;
04-10 10:59:04.755 11928-11928/com.geo.app D/AndroidRuntime﹕ Shutting down VM
04-10 10:59:04.755 11928-11928/com.geo.app W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40028a00)
04-10 10:59:04.775 11928-11928/com.geo.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1654)
at com.geo.app.MainActivity.onCreate(MainActivity.java:26)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
at android.app.ActivityThread.access$2300(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4914)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
04-10 10:59:04.845 104-244/? W/ActivityManager﹕ Force finishing activity com.geo.app/.MainActivity

You are missing a meta tag in the manifest file
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
You don't need these
<permission
android:name="com.geo.app.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
Also it is better to check the availability of google play services before intializing GoogleMap object
Edit:
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
You haven't referenced google play services library project in your android map project.

In your MainActivity.java class change the fragment import statement
import android.support.v4.app.Fragment

Related

Getting long and lat returns a nullpointexception in android map v2

I tried following the tutorial from Google here. I believe I followed every instruction written but I still get nullpointexception when I try to get my long and lat coordinates.
It works fine if I press the target icon in the map that redirects me to my current location. But when I try it programmatically, it returns nullpointexception. I tried looking in stackoverflow for similar situations like mine but so far none of them works.
If you can provide me with a sample working source file or code that I can test myself it is much appreciated. Below are my source code in case I missed something. Thanks in advance.
manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sample.map.activity"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.CAMERA" />
<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:name="android.hardware.camera"
android:required="false" />
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="sample.map.activity"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<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.android.maps.v2.API_KEY"
android:value="AIzaSyAdqod8BHch40COYn19c6Ds0uhyfkX25SA" />
</application>
</manifest>
map activity class
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
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.LatLng;
public class MapActivity extends ActionBarActivity {
GoogleMap map;
Location location;
LatLng myLocation;
LocationManager lm;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
lm = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = lm.getBestProvider(criteria, true);
map = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
map.setMyLocationEnabled(true);
location = lm.getLastKnownLocation(provider);
double mLat = location.getLatitude();
double mLong = location.getLongitude();
Toast.makeText(getApplicationContext(), mLat+" "+mLong, Toast.LENGTH_LONG).show();
map.animateCamera(CameraUpdateFactory.newLatLngZoom(myLocation, 13));
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.map, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Here is the stack trace
05-18 22:45:44.043: E/AndroidRuntime(1220): FATAL EXCEPTION: main
05-18 22:45:44.043: E/AndroidRuntime(1220): Process: sample.map.activity, PID: 1220
05-18 22:45:44.043: E/AndroidRuntime(1220): java.lang.RuntimeException: Unable to start activity ComponentInfo{sample.map.activity/sample.map.activity.MapActivity}: java.lang.NullPointerException
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.os.Handler.dispatchMessage(Handler.java:102)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.os.Looper.loop(Looper.java:136)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.app.ActivityThread.main(ActivityThread.java:5017)
05-18 22:45:44.043: E/AndroidRuntime(1220): at java.lang.reflect.Method.invokeNative(Native Method)
05-18 22:45:44.043: E/AndroidRuntime(1220): at java.lang.reflect.Method.invoke(Method.java:515)
05-18 22:45:44.043: E/AndroidRuntime(1220): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-18 22:45:44.043: E/AndroidRuntime(1220): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-18 22:45:44.043: E/AndroidRuntime(1220): at dalvik.system.NativeStart.main(Native Method)
05-18 22:45:44.043: E/AndroidRuntime(1220): Caused by: java.lang.NullPointerException
05-18 22:45:44.043: E/AndroidRuntime(1220): at sample.map.activity.MapActivity.onCreate(MapActivity.java:39)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.app.Activity.performCreate(Activity.java:5231)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-18 22:45:44.043: E/AndroidRuntime(1220): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
05-18 23:04:59.383: W/ActivityThread(1354): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
05-18 23:04:59.813: I/Process(1354): Sending signal. PID: 1354 SIG: 9
05-18 23:05:01.123: D/dalvikvm(1401): GC_FOR_ALLOC freed 89K, 6% free 2960K/3128K, paused 26ms, total 28ms
05-18 23:05:01.123: I/dalvikvm-heap(1401): Grow heap (frag case) to 3.569MB for 635812-byte allocation
05-18 23:05:01.163: D/dalvikvm(1401): GC_FOR_ALLOC freed 2K, 5% free 3578K/3752K, paused 32ms, total 32ms
05-18 23:05:01.253: W/Visite Dates(1401): Reselected 0 tab name Unposted
05-18 23:05:01.463: D/(1401): HostConnection::get() New Host Connection established 0xb82b7f80, tid 1401
05-18 23:05:01.513: W/EGL_emulation(1401): eglSurfaceAttrib not implemented
05-18 23:05:01.523: D/OpenGLRenderer(1401): Enabling debug mode 0
05-18 23:51:25.343: W/EGL_emulation(1401): eglSurfaceAttrib not implemented
05-18 23:54:27.943: W/EGL_emulation(1401): eglSurfaceAttrib not implemented
Here is the xml file of my layout.
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
I dont know what you have done in your xml file,but your xml file must look like this:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Also Add the following,
< meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" >
< /meta-data>
in your manifest file immediately below the first meta-data tag(where you have placed your google api key).
Also I havent used the camera code that you have written to animate camera.My code:
CameraPosition cameraPosition = new CameraPosition.Builder().target(
new LatLng(your_lat, your_long)).zoom(12).build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Finally got it to work. It seems that the problem is the network provider.
Instead of using Criteria and getBestProvider I followed this approach. What it does is loop to a list of network provider and returns the best existing provider in your mobile phone manually.

Android Google MapV2 doesn't work on intellijIdea

This is my main class
package com.example.mapv2example;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
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 MyActivity extends FragmentActivity {
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.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;
}
}
Android Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapv2example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<permission
android:name="com.example.mapv2example.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.example.mapv2example.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
>
<activity
android:name="com.example.mapv2example.MyActivity"
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.android.maps.v2.API_KEY"
android:value="MY_API_Key" />
</application>
</manifest>
and the main.xml
<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"
tools:context=".MainActivity" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
I am works on IntellijIdea 12 and I add android support library and google play services but when I try to run my app emulator "unfortunately,mapv2example has stopped" I get map version 2 api key from google also this is my error log
12-26 09:03:12.852: ERROR/AndroidRuntime(1714): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapv2example/com.example.mapv2example.MyActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.mapv2example.MyActivity.onCreate(MyActivity.java:23)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
... 11 more
12-26 09:03:12.996: WARN/ActivityManager(298): Force finishing activity com.example.mapv2example/.MyActivity
12-26 09:03:13.043: WARN/WindowManager(298): Screenshot failure taking screenshot for (328x583) to layer 22010
12-26 09:03:13.652: WARN/ActivityManager(298): Activity pause timeout for ActivityRecord{41896338 u0 com.example.mapv2example/.MyActivity}
12-26 09:03:24.261: WARN/ActivityManager(298): Activity destroy timeout for ActivityRecord{41896338 u0 com.example.mapv2example/.MyActivity}
12-26 09:08:13.061: INFO/Process(1714): Sending signal. PID: 1714 SIG: 9
12-26 09:08:13.071: INFO/ActivityManager(298): Process com.example.mapv2example (pid 1714) has died.
12-26 09:08:13.111: WARN/InputMethodManagerService(298): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#41c4dd88 attribute=null, token = android.os.BinderProxy#41b7fd80
12-26 09:10:33.132: DEBUG/dalvikvm(435): GC_FOR_ALLOC freed 511K, 19% free 3041K/3752K, paused 540ms, total 540ms
12-26 09:20:33.401: INFO/ActivityManager(298): No longer want com.android.exchange (pid 1420): empty for 1804s
12-26 09:21:33.782: INFO/ActivityManager(298): No longer want com.android.browser (pid 1511): empty for 1810s
12-26 09:21:33.844: INFO/ActivityManager(298): No longer want com.android.calendar (pid 1495): empty for 1811s
12-26 09:21:33.897: INFO/ActivityManager(298): No longer want com.android.sharedstoragebackup (pid 1531): empty for 1809s
12-26 09:21:41.868: DEBUG/GCM(490): Ignoring attempt to send heartbeat on dead connection.
12-26 09:23:08.892: DEBUG/dalvikvm(298): GC_FOR_ALLOC freed 1142K, 38% free 7504K/12064K, paused 113ms, total 128ms
12-26 09:26:45.921: INFO/EventLogService(490): Aggregate from 1388066205680 (log), 1388066205680 (data)
Did you compile properly the google play services in your build.gradle... you can follow the steps at the android developers site... http://developer.android.com/google/play-services/setup.html... and maybe you will have to use the gmaps api v3...
regards...!!

Google Maps API v2 - I could not display the Map in my app

I'm new to Google Maps API and I'm trying to display a map in my application. Every try has failed, I don't understand why.
Here the logcat.
<!-- language: c# --> 04-02 02:03:21.259: W/dalvikvm(24325): VFY: unable to resolve virtual method 3693: Lcom/kurtis/myapp/Mapexample;.getFragmentManager ()Landroid/app/FragmentManager;
04-02 02:03:21.269: W/dalvikvm(24325): VFY: unable to resolve virtual method 3693: Lcom/kurtis/myapp/Mapexample;.getFragmentManager ()Landroid/app/FragmentManager;
04-02 02:03:21.279: W/dalvikvm(24325): VFY: unable to resolve instance field 23
04-02 02:03:21.419: W/dalvikvm(24325): Unable to resolve superclass of Lmaps/p/s; (425)
04-02 02:03:21.429: W/dalvikvm(24325): Link of class 'Lmaps/p/s;' failed
04-02 02:03:21.429: W/dalvikvm(24325): Unable to resolve superclass of Lmaps/y/bo; (3818)
04-02 02:03:21.429: W/dalvikvm(24325): Link of class 'Lmaps/y/bo;' failed
04-02 02:03:21.429: W/dalvikvm(24325): Unable to resolve superclass of Lmaps/i/k; (4206)
04-02 02:03:21.429: W/dalvikvm(24325): Link of class 'Lmaps/i/k;' failed
04-02 02:03:21.429: E/dalvikvm(24325): Could not find class 'maps.i.k', referenced from method maps.z.ag.a
04-02 02:03:21.429: W/dalvikvm(24325): VFY: unable to resolve new-instance 3538 (Lmaps/i/k;) in Lmaps/z/ag;
04-02 02:03:21.979: W/dalvikvm(24325): threadid=1: thread exiting with uncaught exception (group=0x40174560)
04-02 02:03:21.979: E/AndroidRuntime(24325): FATAL EXCEPTION: main
04-02 02:03:21.979: E/AndroidRuntime(24325): java.lang.NoSuchMethodError: com.kurtis.myapp.Mapexample.getFragmentManager
04-02 02:03:21.979: E/AndroidRuntime(24325): at com.kurtis.myapp.Mapexample.onCreate(Mapexample.java:26)
04-02 02:03:21.979: E/AndroidRuntime(24325): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-02 02:03:21.979: E/AndroidRuntime(24325): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
04-02 02:03:21.979: E/AndroidRuntime(24325): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
04-02 02:03:21.979: E/AndroidRuntime(24325): at android.app.ActivityThread.access$1500(ActivityThread.java:121)
04-02 02:03:21.979: E/AndroidRuntime(24325): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
04-02 02:03:21.979: E/AndroidRuntime(24325): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 02:03:21.979: E/AndroidRuntime(24325): at android.os.Looper.loop(Looper.java:130)
04-02 02:03:21.979: E/AndroidRuntime(24325): at android.app.ActivityThread.main(ActivityThread.java:3768)
04-02 02:03:21.979: E/AndroidRuntime(24325): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 02:03:21.979: E/AndroidRuntime(24325): at java.lang.reflect.Method.invoke(Method.java:507)
04-02 02:03:21.979: E/AndroidRuntime(24325): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
04-02 02:03:21.979: E/AndroidRuntime(24325): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
04-02 02:03:21.979: E/AndroidRuntime(24325): at dalvik.system.NativeStart.main(Native Method)
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera"
android:required="false"/>
<uses-feature android:name="android.hardware.camera.any"
android:required="false" />
<permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<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:icon="#drawable/icona"
android:label="#string/app_name" >
<activity
android:name="com.kurtis.myapp.Home"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.kurtis.myapp.Mapexample"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaXXXXXXXXXXXXXXXXXXXXXXXXXq9M" />
</application>
</manifest>
Activity:
package com.kurtis.myapp;
import com.example.android.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
#SuppressLint("NewApi")
#TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class Mapexample extends FragmentActivity {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapexample);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
// The Map is verified. It is now safe to manipulate the map.
}
}
}
}
...and layout:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
Have you got any idea to solve this problem?
P.S. sorry for my bad english...
Because You writing your application targeting SDK 9, and you use SupportMapFragment (as you should) in your XML file. Then you have to use getSupportFragmentManager and SupportMapFragment method.
Like that:
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
instead of this:
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
It looks like it isn't able to find the maps API. Have you downloaded and configured the Google Play services SDK: https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key
?
Use getSupportFragmentManager() instead of getFragmentManager(). The latter is only defined since Honecomb (and your minsdk is GingerBread) while the former is defined in the support library (that I see you are using since you extend FragmentActivity).
That's why you had to add #TargetApi and #SupressLint... ADT was warning you and you silenced it... =) You should remove those.
In xml file use android:name="com.google.android.gms.maps.SupportMapFragment" instead of
class="com.google.android.gms.maps.SupportMapFragment"
Let me know it`s working

Google Maps Android API v2- error while compiling my android application

Current Status: PROBLEM HAS NOT SOLVED YET- NEED HELP..
Im now developing a map app by using the new google maps Android v2..Before I apply it into my real app..I did a testing..and tried to make it works..I followed the documentation by Google Developers
But seems there are some part I missed, But couldn't find them.. Can u identify them for me? I willl give u my source code below...to let u see them clearly..
Here my current MainActivity class(updated): <---I have only this class in my program
package com.madcatworld.demomapv2;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment fragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.map, fragment).commit();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Here is my activity_main.xml: (updated)
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
Here is my Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.madcatworld.demomapv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<permission
android:name="com.madcatworld.demomapv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.madcatworld.demomapv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<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="xxxxxxxxxxxxxxx" />
<activity
android:name="com.madcatworld.demomapv2.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>
</application>
</manifest>
My emulator: a dialog "Get Google Play Services" appear..when I clicked it...a few errors occur as below..
my current error log(updated) it seems shorter than previous error!! :) :
01-25 04:23:18.647: E/AndroidRuntime(503): FATAL EXCEPTION: main
01-25 04:23:18.647: E/AndroidRuntime(503): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://play.google.com/store/apps/details?id=com.google.android.gms flg=0x80000 pkg=com.android.vending }
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.Activity.startActivityForResult(Activity.java:2817)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.Activity.startActivity(Activity.java:2923)
01-25 04:23:18.647: E/AndroidRuntime(503): at com.google.android.gms.internal.d$2.onClick(Unknown Source)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.view.View.performClick(View.java:2408)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.view.View$PerformClick.run(View.java:8816)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.os.Handler.handleCallback(Handler.java:587)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.os.Looper.loop(Looper.java:123)
01-25 04:23:18.647: E/AndroidRuntime(503): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-25 04:23:18.647: E/AndroidRuntime(503): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 04:23:18.647: E/AndroidRuntime(503): at java.lang.reflect.Method.invoke(Method.java:521)
01-25 04:23:18.647: E/AndroidRuntime(503): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-25 04:23:18.647: E/AndroidRuntime(503): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-25 04:23:18.647: E/AndroidRuntime(503): at dalvik.system.NativeStart.main(Native Method)
For your information,
I already generate a new api key in my google account by copy my
SHAI num from eclipse..
I did this steps Android Tools> rightclick> Export Signed
Application Packages (to make them link each other, I create new
keystore) My QUESTION IS: should I implement this (no 2)??
Please let me know if u found any mistakes I have made.. thank you
You made a mistake you are trying to access android.R.id.content where in your my activity_main.xml file Mapfragment id is android:id="#+id/map"
So, try this way.
Put this Code in your onCreate(..) method
SupportMapFragment fragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.map, fragment).commit();
instead of this.
SupportMapFragment fragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, fragment).commit();
Instead of using the commit() use the .getMap(); method to get and load the map.
GoogleMap mMap;
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();

Google map android API V2 crashed

I want to load the google map API on my android. I try everything I search but it still crash.
this is my MainActivity.java
package com.example.androidmapsv2;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Show the Up button in the action bar.
getActionBar().setDisplayHomeAsUpEnabled(true);
GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
}
}
This is my layout activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
This is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidmapsv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="16" />
<permission
android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" >
</permission>
<uses-permission android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Require OpenGL ES version 2 -->
<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" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.androidmapsv2.MainActivity"
android:label="aaa" >
<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.android.maps.v2.API_KEY"
android:value="AIzaSyDr9xN8L3sF6W2ZRWmTR7q0lhTeOWhXEfQ" />
</application>
</manifest>
This is the key i've got
This is the libs included (Solved in update)
and i don't have a real android device, so i install it on emulator in this tutorial
This is the logcat
01-09 18:05:19.184: E/Trace(1366): error opening trace file: No such file or directory (2)
01-09 18:05:19.354: W/dalvikvm(1366): Unable to resolve superclass of Lcom/example/androidmapsv2/MainActivity; (5)
01-09 18:05:19.354: W/dalvikvm(1366): Link of class 'Lcom/example/androidmapsv2/MainActivity;' failed
01-09 18:05:19.365: D/AndroidRuntime(1366): Shutting down VM
01-09 18:05:19.365: W/dalvikvm(1366): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
01-09 18:05:19.384: E/AndroidRuntime(1366): FATAL EXCEPTION: main
01-09 18:05:19.384: E/AndroidRuntime(1366): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.androidmapsv2/com.example.androidmapsv2.MainActivity}: java.lang.ClassNotFoundException: com.example.androidmapsv2.MainActivity
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.app.ActivityThread.access$600(ActivityThread.java:130)
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.os.Looper.loop(Looper.java:137)
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-09 18:05:19.384: E/AndroidRuntime(1366): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 18:05:19.384: E/AndroidRuntime(1366): at java.lang.reflect.Method.invoke(Method.java:511)
01-09 18:05:19.384: E/AndroidRuntime(1366): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-09 18:05:19.384: E/AndroidRuntime(1366): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-09 18:05:19.384: E/AndroidRuntime(1366): at dalvik.system.NativeStart.main(Native Method)
01-09 18:05:19.384: E/AndroidRuntime(1366): Caused by: java.lang.ClassNotFoundException: com.example.androidmapsv2.MainActivity
01-09 18:05:19.384: E/AndroidRuntime(1366): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-09 18:05:19.384: E/AndroidRuntime(1366): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-09 18:05:19.384: E/AndroidRuntime(1366): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
01-09 18:05:19.384: E/AndroidRuntime(1366): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
01-09 18:05:19.384: E/AndroidRuntime(1366): ... 11 more
UPDATED
i've tried to copy the google-play-services_lib to workspace and red mark disappear
but it come another error. It missing the google-play-services_lib.jar (the lib folder name + .jar). how to fix it
when i click the google-play-services_lib.jar, the remove button doesn't show up(like picture). However i try remove all Android Dependencies and import the others lib again. now it working, but still crash.
I've tried change
MainActivity extends Activity
To
MainActivity extends FragmentActivity
and the layout
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
it appear another error. help me, now i'm out of solution for this
Finally, i solved my error. It caused by my eclipse (i guess). When you add the library class, it automatically appear "google-play-services_lib.jar", you don't have to do anything. I reinstall Eclipse and everything work fine
I also faces this kind of the problem,when first time coding for the map with API V2.
Just try using the extends with FragmentActivity instead of the Activity
you have to copy the project(goolge_play_services) into your workspace and then attach it to your project. In above image it show the cross red,so select it and remove and then after once again add attach the library with the project.
It is required to use SupportMapFragment if API version is below 11
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
Important
Don't forget to extend your Activity with FragmentActivity
you have to copy the project(goolge_play_services) into your workspace and then attach it to your project.
What you are doing is importing the project and not checkmarking the copy the project into workspace due to which it showing you wrong mark in added libraries.
So just checkmark the the copy the project into workspace while importing the google_play_services project and then attach it to your project.
As here i can see that you are using the api level 8 and AFAIK the "Fragments" are supported from the 11.
So here you need to use the compatible library of the fragments.
And also make sure that you have also imported the library of the google-play-service in your workspace and added it in your application.
You need to edit your application's AndroidManifest.xml file, and add the following declaration within the element. This embeds the version of Google Play services that the app was compiled with.
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />

Categories

Resources