私は 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;
}
}
これを修正するアイデアはありますか?前もって感謝します!