android– 在我的布局中添加mapview的Classnotfoundexception

android– 在我的布局中添加mapview的Classnotfoundexception,第1张

概述我见过这个帖子ClassNotFoundExceptionThrownusingMapView但对我没有帮助.我的清单文件中的代码是:<uses-sdkandroid:minSdkVersion="10"/><uses-permissionandroid:name="android.permission.INTERNET"/><uses-permissionandroid:name="andr

我见过这个帖子

ClassNotFoundException Thrown using MapView
但对我没有帮助.

我的清单文件中的代码是:

<uses-sdk androID:minSdkVersion="10" /><uses-permission androID:name="androID.permission.INTERNET" /><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_LOCATION" /><uses-permission androID:name="androID.permission.ACCESS_GPS" /><uses-permission androID:name="androID.permission.ACCESS_ASSISTED_GPS" /><uses-library androID:name="com.Google.androID.maps" ></uses-library><application    androID:icon="@drawable/ic_launcher"    androID:label="@string/app_name" >    <activity        androID:name=".GoogleMapsGpsActivity"        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>

我的GoogleMapsGpsActivity.java代码是:

public class GoogleMapsGpsActivity extends MapActivity {    private LocationManager lm;    private LocationListener locationListener;    private MapVIEw mapVIEw;    private MapController mc;    /** Called when the activity is first created. */    @OverrIDe    public voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.main);         //---use the LocationManager class to obtain GPS locations---        lm = (LocationManager)             getSystemService(Context.LOCATION_SERVICE);            locationListener = new MyLocationListener();        lm.requestLocationUpdates(            LocationManager.GPS_PROVIDER,             0,             0,             locationListener);        mapVIEw = (MapVIEw) findVIEwByID(R.ID.mapvIEw);        mc = mapVIEw.getController();    }    @OverrIDe    protected boolean isRoutedisplayed() {        // Todo auto-generated method stub        return false;    }            private class MyLocationListener implements LocationListener     {        @OverrIDe        public voID onLocationChanged(Location loc) {            if (loc != null) {                                Toast.makeText(getBaseContext(),                     "Location changed : Lat: " + loc.getLatitude() +                     " Lng: " + loc.getLongitude(),                     5000).show();                GeoPoint p = new GeoPoint(                        (int) (loc.getLatitude() * 1E6),                         (int) (loc.getLongitude() * 1E6));                mc.animateto(p);                mc.setZoom(16);                                mapVIEw.invalIDate();            }        }        @OverrIDe        public voID onProvIDerDisabled(String provIDer) {            // Todo auto-generated method stub        }        @OverrIDe        public voID onProvIDerEnabled(String provIDer) {            // Todo auto-generated method stub        }        @OverrIDe        public voID onStatusChanged(String provIDer, int status,             Bundle extras) {            // Todo auto-generated method stub        }    }  }

main.xml中:

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:ID="@+ID/mainlayout"    androID:orIEntation="vertical"    androID:layout_wIDth="fill_parent"    androID:layout_height="fill_parent" >    <com.Googlemaps.gpsapp.MapVIEw        androID:ID="@+ID/mapvIEw"        androID:layout_wIDth="fill_parent"        androID:layout_height="fill_parent"        androID:APIKey="key"    /></linearLayout>

我从以下logcat输出中可以看到ClassNotFoundException

1-02 12:44:17.156: E/AndroIDRuntime(1585): FATAL EXCEPTION: main01-02 12:44:17.156: E/AndroIDRuntime(1585): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.Googlemaps.gpsapp/com.Googlemaps.gpsapp.GoogleMapsGpsActivity}: java.lang.classNotFoundException: com.Googlemaps.gpsapp.GoogleMapsGpsActivity in loader dalvik.system.PathClassLoader[/data/app/com.Googlemaps.gpsapp-2.apk]01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:1569)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.app.ActivityThread.access00(ActivityThread.java:117)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:931)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.os.Handler.dispatchMessage(Handler.java:99)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.os.Looper.loop(Looper.java:130)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.app.ActivityThread.main(ActivityThread.java:3683)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at java.lang.reflect.Method.invokeNative(Native Method)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at java.lang.reflect.Method.invoke(Method.java:507)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:597)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at dalvik.system.NativeStart.main(Native Method)01-02 12:44:17.156: E/AndroIDRuntime(1585): Caused by: java.lang.classNotFoundException: com.Googlemaps.gpsapp.GoogleMapsGpsActivity in loader dalvik.system.PathClassLoader[/data/app/com.Googlemaps.gpsapp-2.apk]01-02 12:44:17.156: E/AndroIDRuntime(1585):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at java.lang.classLoader.loadClass(ClassLoader.java:551)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at java.lang.classLoader.loadClass(ClassLoader.java:511)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.app.Instrumentation.newActivity(Instrumentation.java:1021)01-02 12:44:17.156: E/AndroIDRuntime(1585):     at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:1561)01-02 12:44:17.156: E/AndroIDRuntime(1585):     ... 11 more

请指出我的错误

编辑

感谢大家的回复,错误是在我的main.xml中声明mapvIEw

应该是这样的

<com.Google.androID.maps.MapVIEw        androID:ID="@+ID/mapvIEw"        androID:layout_wIDth="fill_parent"        androID:layout_height="fill_parent"        androID:APIKey="key"    />

而不是上面发布的那个.

解决方法:

请记住,您需要声明< uses-library> < application>内的标记标签.

<application>    ........    <uses-library androID:name="com.Google.androID.maps">    <activity>         ......       ......    </activity></application>

最终的解决方案:

<application    androID:icon="@drawable/ic_launcher"    androID:label="@string/app_name" ><uses-library androID:name="com.Google.androID.maps" > </uses-library>// This should be here    <activity        androID:name=".GoogleMapsGpsActivity"        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>
总结

以上是内存溢出为你收集整理的android – 在我的布局添加mapview的Classnotfoundexception全部内容,希望文章能够帮你解决android – 在我的布局中添加mapview的Classnotfoundexception所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1105681.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存