无法实例化活动ComponentInfo

时间:2011-09-07 18:41:40

标签: android exception google-maps instantiation

我在我的应用中创建了一个地图视图,我收到了这个错误:

09-07 21:24:08.886: INFO/ActivityManager(243): Starting: Intent { cmp=com.android.upvar/.mapsView } from pid 7625
09-07 21:24:08.890: WARN/ActivityManager(243): Trying to launch com.android.upvar/.mapsView
09-07 21:24:08.940: INFO/AudioHardwareALSA(139): Initialized ALSA PLAYBACK device AndroidPlayback_Speaker_normal
09-07 21:24:08.940: VERBOSE/AudioHardwareALSA(139): Set PLAYBACK PCM format to S16_LE (Signed 16 bit Little Endian)
09-07 21:24:08.940: DEBUG/AudioHardwareALSA(139): Using 2 channels for PLAYBACK.
09-07 21:24:08.940: INFO/AudioHardwareALSA(139): DEFAULT_SAMPLE_RATE is 44100, mDefaults->sampleRate is 44100
09-07 21:24:08.940: DEBUG/AudioHardwareALSA(139): Set PLAYBACK sample rate to 44100 HZ
09-07 21:24:08.940: DEBUG/AudioHardwareALSA(139): Buffer size: 4096
09-07 21:24:08.940: DEBUG/AudioHardwareALSA(139): Latency: 92879
09-07 21:24:08.966: WARN/AudioFlinger(139): write blocked for 81 msecs, 55 delayed writes, thread 0x2fee8
09-07 21:24:09.090: INFO/StatusBarPolicy(702): onSignalStrengthsChanged
09-07 21:24:09.213: DEBUG/dalvikvm(7625): newInstance failed: no <init>()
09-07 21:24:09.226: DEBUG/AndroidRuntime(7625): Shutting down VM
09-07 21:24:09.226: WARN/dalvikvm(7625): threadid=1: thread exiting with uncaught exception (group=0x40015578)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625): FATAL EXCEPTION: main
09-07 21:24:09.230: ERROR/AndroidRuntime(7625): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.upvar/com.android.upvar.mapsView}: java.lang.InstantiationException: com.android.upvar.mapsView
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.os.Looper.loop(Looper.java:130)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.app.ActivityThread.main(ActivityThread.java:3687)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at java.lang.reflect.Method.invokeNative(Native Method)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at java.lang.reflect.Method.invoke(Method.java:507)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at dalvik.system.NativeStart.main(Native Method)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625): Caused by: java.lang.InstantiationException: com.android.upvar.mapsView
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at java.lang.Class.newInstanceImpl(Native Method)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at java.lang.Class.newInstance(Class.java:1409)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
09-07 21:24:09.230: ERROR/AndroidRuntime(7625):     ... 11 more
09-07 21:24:09.246: VERBOSE/AudioPolicyManager(139): stopOutput() output 1, stream 1, session 94
09-07 21:24:09.246: VERBOSE/AudioPolicyManager(139): getNewDevice() selected device 0
09-07 21:24:09.246: VERBOSE/AudioPolicyManager(139): setOutputDevice() output 1 device 0 delayMs 0 force 0
09-07 21:24:09.246: VERBOSE/AudioPolicyManager(139): setOutputDevice() setting same device 0 or null device for output 1
09-07 21:24:09.246: WARN/ActivityManager(243):   Force finishing activity com.android.upvar/.mapsView
09-07 21:24:09.246: WARN/ActivityManager(243):   Force finishing activity com.android.upvar/.menu

这是一个简单的地图活动:

public class mapsView extends MapActivity{


        private final Context mContext;

        @Override
        protected boolean isRouteDisplayed() {
            // TODO Auto-generated method stub
            return false;
        }

        //Constructor
        public mapsView(Context ctx){
            this.mContext = ctx;    
        }

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

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

以此意图召唤:

public static Intent mapIntent(Context context){
    Intent i = new Intent(context, mapsView.class);
    return i;
}

当我搜索错误时,我发现它可能是由一些常见错误产生的,因为在应用程序标记之外设置地图库使用权限或者不使用互联网使用权限。但是我把这些东西弄好了,所以我真的不知道那里发生了什么。

1 个答案:

答案 0 :(得分:1)

您的活动不能包含Context参数的构造函数。删除它,一切都会工作。

相关问题