关于开展类ActivityNotFoundException是在明显 [英] ActivityNotFoundException on launching class that is in manifest

查看:187
本文介绍了关于开展类ActivityNotFoundException是在明显的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主类启动应用程序(或至少这是我希望发生的)其他两班。主类 WhenIGetToActivity 启动拳头类 CreateLoc 没有错误,但是,试图发起第二<$ C抛出ActivityNotFoundException $ C>菜单。

I have an app with the main class launching (or at least this is what I want to happen) two other classes. The main class WhenIGetToActivity launches the fist class CreateLoc without error but throws an ActivityNotFoundException on trying to launch the second Menu.

下面是相关的code中的 WhenIGetToActivity

Here is the relevant code from the WhenIGetToActivity

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Intent myIntent = new Intent(getApplicationContext(), Menu.class);
    startActivity(myIntent);
    return true;
}
...

public boolean onTap(final GeoPoint p, final MapView mapView) {
        boolean tapped = super.onTap(p, mapView);
        if (tapped) {
            Intent myIntent = new Intent(getApplicationContext(), CreateLoc.class);
            startActivity(myIntent);
        } else {

两个次级类是正确的(和同)包,既延伸活动

下面是我的清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="SandS.Geo.Cal"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="10" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application>
   android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <uses-library android:name="com.google.android.maps" />

    <activity
        android:name=".WhenIGetToActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="CreateLoc" >
    </activity>
    <activity android:name="Menu" >
    </activity>
</application>

下面是logcat的

06-21 17:30:21.479: I/ApplicationPackageManager(3891): cscCountry is not German : XEU
06-21 17:30:22.289: W/TAG(3891): Location unknown
06-21 17:30:22.329: I/MapActivity(3891): Handling network change notification:CONNECTED
06-21 17:30:22.329: E/MapActivity(3891): Couldn't get connection factory client
06-21 17:30:27.189: W/KeyCharacterMap(3891): No keyboard for id 0
06-21 17:30:27.189: W/KeyCharacterMap(3891): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
06-21 17:30:27.229: D/AndroidRuntime(3891): Shutting down VM
06-21 17:30:27.229: W/dalvikvm(3891): threadid=1: thread exiting with uncaught exception (group=0x40018578)
06-21 17:30:27.239: E/AndroidRuntime(3891): FATAL EXCEPTION: main
06-21 17:30:27.239: E/AndroidRuntime(3891): android.content.ActivityNotFoundException: Unable to find explicit activity class {SandS.Geo.Cal/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.app.Activity.startActivityForResult(Activity.java:2827)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.app.Activity.startActivity(Activity.java:2933)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at SandS.Geo.Cal.WhenIGetToActivity.onCreateOptionsMenu(WhenIGetToActivity.java:62)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.app.Activity.onCreatePanelMenu(Activity.java:2158)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:325)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:570)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1220)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1727)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2627)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2602)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1874)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.os.Looper.loop(Looper.java:130)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at android.app.ActivityThread.main(ActivityThread.java:3687)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at java.lang.reflect.Method.invokeNative(Native Method)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at java.lang.reflect.Method.invoke(Method.java:507)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
06-21 17:30:27.239: E/AndroidRuntime(3891):     at dalvik.system.NativeStart.main(Native Method)

我曾尝试清洁项目。

I have tried Cleaning the Project.

任何想法。

继4答案我改变类的名称的建议,我在现在被称为这样做它 StevesToolsMenu.class

Following suggestions from 4 answers that I change the name of the class, I have done so it in now called StevesToolsMenu.class

新的 onCreateOptionsMenu 现在有一行:

Intent myIntent = new Intent(getApplicationContext(), StevesToolsMenu.class);

清单文件的相关部分现在是:

The relevant part of the manifest file is now:

<application>
   android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <uses-library android:name="com.google.android.maps" />

    <activity
        android:name=".WhenIGetToActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".CreateLoc" >
    </activity>
    <activity android:name=".StevesToolsMenu" >
    </activity>
</application>

新logcat的是:

The new Logcat is:

06-23 15:14:22.989: I/ApplicationPackageManager(4088): cscCountry is not German : XEU
06-23 15:14:23.789: W/TAG(4088): Location unknown
06-23 15:14:23.849: I/MapActivity(4088): Handling network change notification:CONNECTED
06-23 15:14:23.849: E/MapActivity(4088): Couldn't get connection factory client
06-23 15:14:30.219: W/KeyCharacterMap(4088): No keyboard for id 0
06-23 15:14:30.219: W/KeyCharacterMap(4088): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
06-23 15:14:30.289: I/ApplicationPackageManager(4088): cscCountry is not German : XEU
06-23 15:14:30.319: D/AndroidRuntime(4088): Shutting down VM
06-23 15:14:30.319: W/dalvikvm(4088): threadid=1: thread exiting with uncaught exception (group=0x40018578)
06-23 15:14:30.329: E/AndroidRuntime(4088): FATAL EXCEPTION: main
06-23 15:14:30.329: E/AndroidRuntime(4088): java.lang.RuntimeException: Unable to start activity ComponentInfo{SandS.Geo.Cal/SandS.Geo.Cal.StevesToolsMenu}: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.os.Looper.loop(Looper.java:130)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.app.ActivityThread.main(ActivityThread.java:3687)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at java.lang.reflect.Method.invokeNative(Native Method)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at java.lang.reflect.Method.invoke(Method.java:507)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at dalvik.system.NativeStart.main(Native Method)
06-23 15:14:30.329: E/AndroidRuntime(4088): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.app.Activity.setContentView(Activity.java:1657)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at SandS.Geo.Cal.StevesToolsMenu.onCreate(StevesToolsMenu.java:20)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
06-23 15:14:30.329: E/AndroidRuntime(4088):     ... 11 more
06-23 15:14:30.329: E/AndroidRuntime(4088): Caused by: java.lang.reflect.InvocationTargetException
06-23 15:14:30.329: E/AndroidRuntime(4088):     at java.lang.reflect.Constructor.constructNative(Native Method)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
06-23 15:14:30.329: E/AndroidRuntime(4088):     ... 21 more
06-23 15:14:30.329: E/AndroidRuntime(4088): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity.
06-23 15:14:30.329: E/AndroidRuntime(4088):     at com.google.android.maps.MapView.<init>(MapView.java:291)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at com.google.android.maps.MapView.<init>(MapView.java:264)
06-23 15:14:30.329: E/AndroidRuntime(4088):     at com.google.android.maps.MapView.<init>(MapView.java:247)
06-23 15:14:30.329: E/AndroidRuntime(4088):     ... 24 more

我们似乎已更换了一个问题与另一个(或者说发现了第二个问题)。

We seem to have replaced one problem with another (or rather uncovered a second problem).

你看它无论怎样,我还是觉得很难理解为什么一个类应该工作,另一个(看似相同的方式设置)类没有。

Whichever way you look at it, I still find it difficult to understand why one class should work and another (setup in seemingly the same way) class does not.

推荐答案

您试图启动一个名为活动 android.view.Menu 。您不必命名的活动 android.view.Menu 。你有,出于某种原因,被命名为活动 SandS.Geo.Cal.Menu

You are trying to start an activity named android.view.Menu. You do not have an activity named android.view.Menu. You have an activity that, for some reason, is named SandS.Geo.Cal.Menu.

意图myIntent =新意图(getApplicationContext(),Menu.class);

Intent myIntent = new Intent(getApplicationContext(), Menu.class);

如果你改变的第二个参数的意图构造的对象为您的活动,很可能会导致更好地工作。更妙的是不要有一个名为活动菜单,但使用的东西比较有特色的,以帮助prevent这种碰撞的未来。

If you change the second parameter of the Intent constructor to the Class object for your activity, that will likely work better. Even better would be to not have an activity named Menu, but to use something more distinctive, to help prevent this sort of collision in the future.

这篇关于关于开展类ActivityNotFoundException是在明显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆