my google map v2 test apps crashes - android

i am newcomer on stackoverflow and
i have google map test project that use from
here
and i do just like tutorial but apps crashes.
i done every single steps in tutorial and get android key, added library and more:
my similar problem is this link:
here
but it don't have any answer that works.
i completly delete eclips, uninstall java JDK and JRE and even my whole system java. but the app is crashes.
can any body help me on this? thank you very much
here my code:
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NavUtils;
public class MainActivity extends FragmentActivity {
private GoogleMap googleMap;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
private void initilizeMap() {
if (googleMap == null) {
//googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
}
and manifest file is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.maptest"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.test.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.test.maptest.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBYju6h2BWvZOaSDQpe5f9tv6fJsZy6cY8" />
</manifest>
and layout is:
<?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>
and this is logcat:
11-25 14:04:50.663: E/Trace(1411): error opening trace file: No such file or directory (2)
11-25 14:04:50.853: D/AndroidRuntime(1411): Shutting down VM
11-25 14:04:50.853: W/dalvikvm(1411): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-25 14:04:50.873: E/AndroidRuntime(1411): FATAL EXCEPTION: main
11-25 14:04:50.873: E/AndroidRuntime(1411): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ariagostar.maptest/com.ariagostar.maptest.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.os.Handler.dispatchMessage(Handler.java:99)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.os.Looper.loop(Looper.java:137)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-25 14:04:50.873: E/AndroidRuntime(1411): at java.lang.reflect.Method.invokeNative(Native Method)
11-25 14:04:50.873: E/AndroidRuntime(1411): at java.lang.reflect.Method.invoke(Method.java:511)
11-25 14:04:50.873: E/AndroidRuntime(1411): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-25 14:04:50.873: E/AndroidRuntime(1411): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-25 14:04:50.873: E/AndroidRuntime(1411): at dalvik.system.NativeStart.main(Native Method)
11-25 14:04:50.873: E/AndroidRuntime(1411): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-25 14:04:50.873: E/AndroidRuntime(1411): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.Activity.setContentView(Activity.java:1867)
11-25 14:04:50.873: E/AndroidRuntime(1411): at com.ariagostar.maptest.MainActivity.onCreate(MainActivity.java:25)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.Activity.performCreate(Activity.java:5008)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-25 14:04:50.873: E/AndroidRuntime(1411): ... 11 more
11-25 14:04:50.873: E/AndroidRuntime(1411): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.support.v4.app.Fragment.instantiate(Fragment.java:388)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.support.v4.app.Fragment.instantiate(Fragment.java:363)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:264)
11-25 14:04:50.873: E/AndroidRuntime(1411): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)

Change
public class MainActivity extends FragmentActivity {
to
public class MainActivity extends Activity {
Change this
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
to
googleMap = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
You also need the below in application tag in manifest
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
which is a requirement of google play services rev 13
Edit:
Move
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBYju6h2BWvZOaSDQpe5f9tv6fJsZy6cY8" />
inside application tag in manifest

Try with this.
Your MainActivity
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
// Valida si el mapa no se creo correctamente
if (googleMap == null) {
Toast.makeText(getApplicationContext(), "Sorry! el mapa no pudo ser cargado", Toast.LENGTH_SHORT)
.show();
}
}
}
In your layout this
<?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:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
In the manifest, i used this lines in MAC, because in Windows works correctly works without them
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />

I had a similar problemt. For me adding:
import com.google.android.gms.maps.SupportMapFragment;
And changing the xml to
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/header" />
resolved the problem. I hope you resolve it too!

Related

Android Google Map error, Unable to start activity ComponentInfo

I have tried a small example in Google map. I have got the API key but when I run the project, it displays the following errors. I have also imported Google play services.
My XML file
<?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.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
My Java
package com.arun.maps;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.Toast;
public class GoogleMapS extends FragmentActivity {
private GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.google_map);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
super.onResume();
initilizeMap();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.google_map, menu);
return true;
}
}
Android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.arun.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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.arun.maps.GoogleMapS"
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="
AIzaSyBn3b2eGABl1JL-xXKe1H_uf4UtPRUUAwY" />
</application>
</manifest>
Error:
04-02 17:21:39.355: E/AndroidRuntime(719): FATAL EXCEPTION: main
04-02 17:21:39.355: E/AndroidRuntime(719): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.arun.maps/com.arun.maps.GoogleMapS}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.os.Looper.loop(Looper.java:130)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-02 17:21:39.355: E/AndroidRuntime(719): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 17:21:39.355: E/AndroidRuntime(719): at java.lang.reflect.Method.invoke(Method.java:507)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-02 17:21:39.355: E/AndroidRuntime(719): at dalvik.system.NativeStart.main(Native Method)
04-02 17:21:39.355: E/AndroidRuntime(719): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.Activity.setContentView(Activity.java:1657)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.arun.maps.GoogleMapS.onCreate(GoogleMapS.java:16)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-02 17:21:39.355: E/AndroidRuntime(719): ... 11 more
04-02 17:21:39.355: E/AndroidRuntime(719): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.internal.q.B(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.internal.q.A(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.SupportMapFragment$b.gW(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.dynamic.a.a(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
04-02 17:21:39.355: E/AndroidRuntime(719): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-02 17:21:39.355: E/AndroidRuntime(719): ... 20 more
Add this in manifest file's application tag.
<!-- Required after latest Google Play Services update -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Add this in manifest file inside your application tag:
<meta-data
android:name="com.google.android.gms.version"
android:value="4242000" />

Error inflating class fragment on Google Maps V2

I develop an application and I need to see the Google Maps v2.
The main class is:
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
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.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.app.Activity;
public class MapsV2 extends FragmentActivity {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapsv2);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
final LatLng CIU = new LatLng(35.21843892856462, 33.41662287712097);
Marker ciu = mMap.addMarker(new MarkerOptions()
.position(CIU).title("My Office"));
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_page_option_menu, menu);
return true;
}
}
And the XML is:
<?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"
android:name="com.app.reminder.MapsV2"/>
So, when I run it on my device I've got error message:
02-18 14:20:37.596: E/AndroidRuntime(30383): FATAL EXCEPTION: main
02-18 14:20:37.596: E/AndroidRuntime(30383): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.reminder/com.app.reminder.MapsV2}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.access$600(ActivityThread.java:140)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.os.Handler.dispatchMessage(Handler.java:99)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.os.Looper.loop(Looper.java:137)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.main(ActivityThread.java:4898)
02-18 14:20:37.596: E/AndroidRuntime(30383): at java.lang.reflect.Method.invokeNative(Native Method)
02-18 14:20:37.596: E/AndroidRuntime(30383): at java.lang.reflect.Method.invoke(Method.java:511)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
02-18 14:20:37.596: E/AndroidRuntime(30383): at dalvik.system.NativeStart.main(Native Method)
02-18 14:20:37.596: E/AndroidRuntime(30383): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.Activity.setContentView(Activity.java:1924)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.app.reminder.MapsV2.onCreate(MapsV2.java:22)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.Activity.performCreate(Activity.java:5206)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
02-18 14:20:37.596: E/AndroidRuntime(30383): ... 11 more
02-18 14:20:37.596: E/AndroidRuntime(30383): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4132500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.internal.q.v(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.internal.q.u(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.SupportMapFragment$b.eb(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.dynamic.a.a(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
02-18 14:20:37.596: E/AndroidRuntime(30383): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
02-18 14:20:37.596: E/AndroidRuntime(30383): ... 20 more
The manifest is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.reminder"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
<permission
android:name="com.app.reminder.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.app.reminder.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="com.app.reminder.InfoManager">
>
<activity
android:name="SplashScreen"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="MapsV2"></activity><uses-library android:name="com.google.android.maps"
/>
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBDtXP5sYucD8z5pjaJFuvt43sLWOGzyuQ" />
<activity android:name="MapsV2"></activity>
</application>
</manifest>
I tried all the options in the answers in StackOverFlow.
The log is quite clear, you are missing this line in your manifest:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
As you can read at the end of this line:
Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4132500 but found 0. You must have the following declaration within the <application> element:<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
Also, take care to have the last version of Google Play services(version 13 or more), and not Google Play services for Froyo, who doesn't contain that parameter.
You should replace this
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
With
mMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
Replace your Fragment
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
In manifest.xml
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
Activity class
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleMap gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

Google Maps API 2 for Android “Unfortunately, application has stopped."

I am android beginner, I follow a tutorial and try to show the google map using android. and I've also checked the other similar questions asked here, but am still unable to load a map :
logcat:
12-29 14:16:53.025: E/AndroidRuntime(4499): FATAL EXCEPTION: main
12-29 14:16:53.025: E/AndroidRuntime(4499): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gmapsapp/com.example.gmapsapp.MainActivity}: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.app.ActivityThread.access$600(ActivityThread.java:140)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.os.Handler.dispatchMessage(Handler.java:99)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.os.Looper.loop(Looper.java:137)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.app.ActivityThread.main(ActivityThread.java:4898)
12-29 14:16:53.025: E/AndroidRuntime(4499): at java.lang.reflect.Method.invokeNative(Native Method)
12-29 14:16:53.025: E/AndroidRuntime(4499): at java.lang.reflect.Method.invoke(Method.java:511)
12-29 14:16:53.025: E/AndroidRuntime(4499): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
12-29 14:16:53.025: E/AndroidRuntime(4499): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
12-29 14:16:53.025: E/AndroidRuntime(4499): at dalvik.system.NativeStart.main(Native Method)
12-29 14:16:53.025: E/AndroidRuntime(4499): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
12-29 14:16:53.025: E/AndroidRuntime(4499): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-29 14:16:53.025: E/AndroidRuntime(4499): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-29 14:16:53.025: E/AndroidRuntime(4499): at com.example.gmapsapp.MainActivity.servicesOK(MainActivity.java:40)
12-29 14:16:53.025: E/AndroidRuntime(4499): at com.example.gmapsapp.MainActivity.onCreate(MainActivity.java:22)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.app.Activity.performCreate(Activity.java:5206)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
12-29 14:16:53.025: E/AndroidRuntime(4499): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
12-29 14:16:53.025: E/AndroidRuntime(4499): ... 11 more
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gmapsapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.gmapsapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.gmapsapp.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-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" >
<activity
android:name="com.example.gmapsapp.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="mykey"/>
</application>
</manifest>
MainActivity
package com.example.gmapsapp;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.Toast;
public class MainActivity extends FragmentActivity {
private static final int GPS_ERRORDIALOG_REQUEST = 9001;
GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (servicesOK()) {
Toast.makeText(this, "Ready to map!", Toast.LENGTH_SHORT).show();
setContentView(R.layout.activity_map);
}
else {
setContentView(R.layout.activity_main);
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean servicesOK() {
int isAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (isAvailable == ConnectionResult.SUCCESS) {
return true;
}
else if (GooglePlayServicesUtil.isUserRecoverableError(isAvailable)) {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvailable, this, GPS_ERRORDIALOG_REQUEST);
dialog.show();
}
else {
Toast.makeText(this, "Can't connect to Google Play services", Toast.LENGTH_SHORT).show();
}
return false;
}
}
activity_map
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
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.
This is a new requirement as of the updated google play services which is rev 13 i guess.
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2
There is no need for
<permission
android:name="com.example.gmapsapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
and this
<uses-permission android:name="com.example.gmapsapp.permission.MAPS_RECEIVE"/>
Refer Specifying permission in the above link
try to put
<meta-data
android:name="com.google.android.gms.version"
android:value="key" />
inside your application tag, in AndroidManifest.xml

Google Maps V2 "Unfortunately [app] has Stopped"

i'am new in Android programming i have a problem. When my code running i give error "Unfortunately [app] has Stopped" in my device screen.
This is my Activity
package com.android.markermap;
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 BANDUNG = new LatLng(-6.904955,107.61034);
static final LatLng BOGOR = new LatLng(-6.589581,106.799755);
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 bandung = map.addMarker(new MarkerOptions().position(BANDUNG).title("Berat"));
Marker bogor = map.addMarker(new MarkerOptions().position(BOGOR).title("Ringan").snippet("Kiel is cool"));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(BANDUNG, 12));
// 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;
}
}
This is my layout code
<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>
This is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.markermap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<permission
android:name="com.android.markermap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.android.markermap.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"
android:theme="#style/AppTheme" >
<activity
android:name="com.android.markermap.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="AIzaSyC-0N7OEKJmId5HnKYNsbU6IBaSIgiF7Lc" />
</application>
</manifest>
And this is my error code
11-30 23:39:58.071: W/dalvikvm(16870): threadid=1: thread exiting with uncaught exception (group=0x40c64438)
11-30 23:39:58.071: E/AndroidRuntime(16870): FATAL EXCEPTION: main
11-30 23:39:58.071: E/AndroidRuntime(16870): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.markermap/com.android.markermap.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.access$600(ActivityThread.java:133)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.os.Handler.dispatchMessage(Handler.java:99)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.os.Looper.loop(Looper.java:137)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.main(ActivityThread.java:4810)
11-30 23:39:58.071: E/AndroidRuntime(16870): at java.lang.reflect.Method.invokeNative(Native Method)
11-30 23:39:58.071: E/AndroidRuntime(16870): at java.lang.reflect.Method.invoke(Method.java:511)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
11-30 23:39:58.071: E/AndroidRuntime(16870): at dalvik.system.NativeStart.main(Native Method)
11-30 23:39:58.071: E/AndroidRuntime(16870): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.Activity.setContentView(Activity.java:1867)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.android.markermap.MainActivity.onCreate(MainActivity.java:23)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.Activity.performCreate(Activity.java:5008)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
11-30 23:39:58.071: E/AndroidRuntime(16870): ... 11 more
11-30 23:39:58.071: E/AndroidRuntime(16870): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.MapFragment$b.cE(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.dynamic.a.a(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.app.Activity.onCreateView(Activity.java:4663)
11-30 23:39:58.071: E/AndroidRuntime(16870): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
11-30 23:39:58.071: E/AndroidRuntime(16870): ... 21 more
Anyonee have ide for this problem?
i'am very confuse, i hope u can solve this problem.
actually reading the error help a lot you know
The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
Your code is fine but for Google play service revision 13 you should have to add one more meta tag in your manifest.xml.Insert it inside your application tag.So there will be two meta tags in your application tag.If you still need any help.Just follow this link
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />

Impossible to instantiate an OsmDroid MapView

I'm trying to use OSMdroid for a project, and i'm utterly unable to make the simplest code work.
Well, a few days ago i was able to display maps and so on, and now i can't even instantiate a MapView.
I reduced the code to its sipmlest form.
I work with eclipse. I downloaded osmdroid-android-3.0.5.jar and slf4j-android-1.5.8.jar, and i included them in the project by adding lines to the classpath file
<classpathentry kind="lib" path="lib/osmdroid-android-3.0.5.jar"/>
<classpathentry kind="lib" path="lib/slf4j-android-1.5.8.jar"/>
Or by right clicking on them then Build Path-> Add to build path (both gave the same result, anyway)
Then i typed this code:
import android.app.Activity;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.os.Bundle;
public class TestMapActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mv=new MapView(this,256);
}
}
And i get a bug when running it on the emulator:
04-17 09:10:31.181: E/AndroidRuntime(595): FATAL EXCEPTION: main
04-17 09:10:31.181: E/AndroidRuntime(595): java.lang.NoClassDefFoundError: org.osmdroid.views.MapView
04-17 09:10:31.181: E/AndroidRuntime(595): at testmap.sagem.TestMapActivity.onCreate(TestMapActivity.java:17)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.Activity.performCreate(Activity.java:4465)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.os.Looper.loop(Looper.java:137)
04-17 09:10:31.181: E/AndroidRuntime(595): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-17 09:10:31.181: E/AndroidRuntime(595): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 09:10:31.181: E/AndroidRuntime(595): at java.lang.reflect.Method.invoke(Method.java:511)
04-17 09:10:31.181: E/AndroidRuntime(595): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-17 09:10:31.181: E/AndroidRuntime(595): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-17 09:10:31.181: E/AndroidRuntime(595): at dalvik.system.NativeStart.main(Native Method)
When i comment out the "MapView mv=new MapView(this,256);" it works, so i don't understand why the mapview can't be instantiated.
Any idea on this?
Thank you for your attention.
EDIT:
The AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="testmap.sagem"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".TestMapActivity"
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>
The main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
Change Folder name "lib" to "libs" and put all jar files in that folder and Charge path of jar
files to "libs" folder. I am not sure but I think it will work.
Try to use the 3.0.7 and clean the project.
Let me know.
http://code.google.com/p/osmdroid/downloads/list

Categories

Resources