应用程序XXX意外停止。请再试一次

时间:2013-03-19 02:20:26

标签: android

我是Android新手,我正在根据地图构建应用。当我尝试启动我的应用程序时,出现错误,“应用程序AdBaiduMapDemo02意外停止。请再试一次。” 以下是LogCat的说法:

>03-19 09:40:46.983: D/AndroidRuntime(389): Shutting down VM  
>03-19 09:40:46.983: W/dalvikvm(389): threadid=1: thread exiting with uncaught exception (group=0x40015560)  
>03-19 09:40:47.023: E/AndroidRuntime(389): FATAL EXCEPTION: main  
>03-19 09:40:47.023: E/AndroidRuntime(389): java.lang.RuntimeException: Unable to instantiate application com.example.adbaidumapdemo02.AdBaiduMapDemo02: java.lang.ClassNotFoundException: com.example.adbaidumapdemo02.AdBaiduMapDemo02 in loader dalvik.system.PathClassLoader[/data/app/com.example.adbaidumapdemo02-1.apk]  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.app.LoadedApk.makeApplication(LoadedApk.java:466)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3260)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.app.ActivityThread.access$2200(ActivityThread.java:117)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.os.Handler.dispatchMessage(Handler.java:99)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.os.Looper.loop(Looper.java:130)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.app.ActivityThread.main(ActivityThread.java:3683)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at java.lang.reflect.Method.invokeNative(Native Method)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at java.lang.reflect.Method.invoke(Method.java:507)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at dalvik.system.NativeStart.main(Native Method)  
>03-19 09:40:47.023: E/AndroidRuntime(389): Caused by: java.lang.ClassNotFoundException: com.example.adbaidumapdemo02.AdBaiduMapDemo02 in loader dalvik.system.PathClassLoader[/data/app/com.example.adbaidumapdemo02-1.apk]  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.app.Instrumentation.newApplication(Instrumentation.java:942)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     at android.app.LoadedApk.makeApplication(LoadedApk.java:461)  
>03-19 09:40:47.023: E/AndroidRuntime(389):     ... 11 more  

我的MainActivity代码如下:

package com.example.adbaidumapdemo02;  
import com.baidu.mapapi.BMapManager;  
import com.baidu.mapapi.GeoPoint;  
import com.baidu.mapapi.MapActivity;  
import com.baidu.mapapi.MapController;  
import com.baidu.mapapi.MapView;  
import android.os.Bundle;  
public class MainActivity extends MapActivity {  
    BMapManager mBMapMan = null;  
    MapView mMapView = null;  
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        mBMapMan = new BMapManager(getApplication());  
        mBMapMan.init("027FB8C5D701284490FF6C80E66AD7EAB37154C4", null);  
        super.initMapActivity(mBMapMan);  
        mMapView = (MapView)findViewById(R.id.bmapsView);  
        mMapView.setBuiltInZoomControls(true);  
        MapController mMapController = mMapView.getController();  
        GeoPoint point = new GeoPoint((int)(39.915 * 1E6), (int)(116.404 * 1E6));  
        mMapController.setCenter(point);  
        mMapController.setZoom(12);  
    }  
    @Override   
    protected void onDestroy() {  
        if(mBMapMan != null)  
        {  
            mBMapMan.destroy();  
            mBMapMan = null;  
        }  
        super.onDestroy();  
    }     
    @Override  
    protected void onPause() {  
        if (mBMapMan != null)  
        {  
            mBMapMan.stop();  
        }  
        super.onPause();  
    }     
    @Override  
    protected void onResume() {  
        if (mBMapMan != null)  
        {   
            mBMapMan.start();  
        }  
        super.onResume();  
    }  
    @Override  
    protected boolean isRouteDisplayed() {  
        return false;  
    }  
}  

有什么想法解决这个问题吗?提前致谢!

2 个答案:

答案 0 :(得分:1)

  

com.example.adbaidumapdemo02.AdBaiduMapDemo02:java.lang.ClassNotFoundException:

您的AdBaiduMapDemo02.class在哪里?

答案 1 :(得分:0)

您项目中的某个位置引用了Java Class Loader无法找到的类AdBaiduMapDemo02

我建议您在项目中搜索“AdBaiduMapDemo02”