Unable to instantiate activity ComponentInfo
I created a map view in my app and I'm getting this error:
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
It's a simple map activity like this:
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);
}
}
Wich is called with this intent:
public static Intent mapIntent(Context context){
Intent i = n开发者_运维技巧ew Intent(context, mapsView.class);
return i;
}
When I googled the error and I found that it might be produced by some common mistakes as setting the maps library use permission outside the application tag or not putting the internet usage permission. But I got those things right, so I don't really don't know what's going on there.
Your activity mustn't have a constructor with Context
parameter. Remove it and everything will work.
精彩评论