android mapview给了我错误

时间:2012-02-02 04:25:36

标签: android geolocation android-mapview

你好,我想在谷歌地图onn模拟器上显示但它给我跟随错误我正在使用Android谷歌API 2.2

02-02 09:47:21.882: W/dalvikvm(493): Unable to resolve superclass of Landroi/com/MapView/TestingMapViewActivity; (12)
02-02 09:47:21.922: W/dalvikvm(493): Link of class 'Landroi/com/MapView/TestingMapViewActivity;' failed
02-02 09:47:21.952: D/AndroidRuntime(493): Shutting down VM
02-02 09:47:21.962: W/dalvikvm(493): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-02 09:47:22.012: E/AndroidRuntime(493): FATAL EXCEPTION: main
02-02 09:47:22.012: E/AndroidRuntime(493): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{androi.com.MapView/androi.com.MapView.TestingMapViewActivity}: java.lang.ClassNotFoundException: androi.com.MapView.TestingMapViewActivity in loader dalvik.system.PathClassLoader[/data/app/androi.com.MapView-2.apk]
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.os.Looper.loop(Looper.java:123)
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.app.ActivityThread.main(ActivityThread.java:4627)
02-02 09:47:22.012: E/AndroidRuntime(493):  at java.lang.reflect.Method.invokeNative(Native Method)
02-02 09:47:22.012: E/AndroidRuntime(493):  at java.lang.reflect.Method.invoke(Method.java:521)
02-02 09:47:22.012: E/AndroidRuntime(493):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-02 09:47:22.012: E/AndroidRuntime(493):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-02 09:47:22.012: E/AndroidRuntime(493):  at dalvik.system.NativeStart.main(Native Method)
02-02 09:47:22.012: E/AndroidRuntime(493): Caused by: java.lang.ClassNotFoundException: androi.com.MapView.TestingMapViewActivity in loader dalvik.system.PathClassLoader[/data/app/androi.com.MapView-2.apk]
02-02 09:47:22.012: E/AndroidRuntime(493):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-02 09:47:22.012: E/AndroidRuntime(493):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-02 09:47:22.012: E/AndroidRuntime(493):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
02-02 09:47:22.012: E/AndroidRuntime(493):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
02-02 09:47:22.012: E/AndroidRuntime(493):  ... 11 more

我已经完成了这个

package androi.com.MapView;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.os.Bundle;

public class TestingMapViewActivity extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // setContentView(R.layout.main);
        // Intent i = new Intent(TestingMapViewActivity.this, tets.class);
        // startActivity(i);
        MapView mv = new MapView(this,
                "key");
        setContentView(mv);
    }

    @Override
    protected boolean isRouteDisplayed() {

        return false;
    }
![this is snap][1]
}

我也尝试使用XML文件

<?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" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
   <com.google.android.maps.MapView 
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true
        android:apiKey="key" />

manifest资源配置文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="androi.com.MapView"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

     <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" />


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".TestingMapViewActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="tets"></activity>
    </application>
<uses-library android:name="com.google.android.maps" />
</manifest>

4 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

你的Manifest文件中存在问题,

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

应该在下面的内容中

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

答案 2 :(得分:0)

将清单更改为将库使用到应用程序标记中。

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk android:minSdkVersion="8" />

 <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" />


<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".TestingMapViewActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="tets"></activity>
    <uses-library android:name="com.google.android.maps" />
</application>

答案 3 :(得分:0)

您需要在<uses-library android:name="com.google.android.maps" /> 标签

的一侧添加<application>