package com.fio.gmapsactivity;
GMapsActivity
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class GMapsActivity extends MapActivity {
private MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
mapView = (MapView) findViewById(R.id.map_view);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
activity_map.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="AIzaSyB4sGJQVW1hJpOtWnTHvDw5IxV_YOPA9eA"
android:clickable="true"
android:enabled="true" />
</RelativeLayout>
Mainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fio.gmapsactivity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.fio.gmapsactivity.GMapsActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB4sGJQVW1hJpOtWnTHvDw5IxV_YOPA9eA" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
我已经添加了jar文件(效果,地图,usb)。但是无法map.only显示error.can't能找到错误。请帮助我。
错误
02-25 02:49:31.993: E/AndroidRuntime(1812): FATAL EXCEPTION: main
02-25 02:49:31.993: E/AndroidRuntime(1812): java.lang.IllegalAccessError: Class ref in pre- verified class resolved to unexpected implementation
02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.DexFile.defineClass(Native Method)
02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:211)
02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.DexPathList.findClass(DexPathList.java:313)
02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:51)
02-25 02:49:31.993: E/AndroidRuntime(1812): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-25 02:49:31.993: E/AndroidRuntime(1812): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
02-25 02:49:31.993: E/AndroidRuntime(1812): at android.os.Handler.dispatchMessage(Handler.java:99)
02-25 02:49:31.993: E/AndroidRuntime(1812): at android.os.Looper.loop(Looper.java:137)
02-25 02:49:31.993: E/AndroidRuntime(1812): at android.app.ActivityThread.main(ActivityThread.java:5103)
02-25 02:49:31.993: E/AndroidRuntime(1812): at java.lang.reflect.Method.invokeNative(Native Method)
02-25 02:49:31.993: E/AndroidRuntime(1812): at java.lang.reflect.Method.invoke(Method.java:525)
02-25 02:49:31.993: E/AndroidRuntime(1812): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-25 02:49:31.993: E/AndroidRuntime(1812): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-25 02:49:31.993: E/AndroidRuntime(1812): at dalvik.system.NativeStart.main(Native Method)