gpt4 book ai didi

android - 无法实例化 Activity ComponentInfo

转载 作者:行者123 更新时间:2023-11-30 04:33:09 28 4
gpt4 key购买 nike

我在我的应用程序中创建了一个 map View ,但出现了这个错误:

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

这是一个像这样的简单 map Activity :

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 的调用目的是:

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

当我用谷歌搜索这个错误时,我发现它可能是由一些常见的错误产生的,比如在应用程序标签之外设置 map 库使用权限或者没有放置互联网使用权限。但我做对了这些事情,所以我真的不知道那里发生了什么。

最佳答案

您的 Activity 不得有带有 Context 参数的构造函数。删除它,一切都会起作用。

关于android - 无法实例化 Activity ComponentInfo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7338883/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com