0

我需要在物理 Android 设备上运行地图,我该怎么做?

我不想使用 AVD 来调试它。

顺便说一句,我在 AVD 上遇到了同样的错误,所以请帮忙?这是我的代码

<com.google.android.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:apiKey="0enZtoViiB7JtEUxmyjwYWuw0Hz8pdTqNNWtBjQ"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true" />

AndroidManifest.xml

<uses-library android:name="com.google.android.maps" />

活动:

public class AroundMeActivity extends MapActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.qa_layout_activity);

    MapView mapView = (MapView) findViewById(R.id.map);
    mapView.setBuiltInZoomControls(true);
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}
}

STACKTRACE:
at android.app.ActivityThread.main(ActivityThread.java:3683)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
        at dalvik.system.DexFile.defineClass(Native Method)
        at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:207)
        at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:200)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
4

2 回答 2

2

Exception通常意味着您的项目中存在符号冲突。确保您maps.jar在项目中只包含一次。

于 2012-06-14T07:30:44.510 回答
1

第二个.java

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
public class second extends MapActivity 
{

MapView mapView;
Drawable drawable;
LocationManager locationmanager;
private LocationListener locationListener;
MapController mapController;
private String provider;
Location location;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


            mapView = (MapView) findViewById(R.id.MapView);
            mapView.setBuiltInZoomControls(true);
            mapView.setSatellite(true);
            mapView.setStreetView(true);
            mapController = mapView.getController();
            mapController.setZoom(16);

            GeoPoint point = new GeoPoint(lat,lon);
//lat and lon are integer values for describing the location
            mapView.invalidate();
            mapController.animateTo(point);

}

主要的.xml

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/MapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="API key"
/>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.android.gps22"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <application android:icon="@drawable/icon" android:label="@string/app_name">
    <uses-library android:name="com.google.android.maps"/>
        <activity android:name=".second"
                  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>
于 2012-06-13T09:41:49.210 回答