【问题标题】:ActivityNotFoundException while using startActivity(Intent)使用 startActivity(Intent) 时出现 ActivityNotFoundException
【发布时间】:2014-05-17 05:45:29
【问题描述】:

这里是错误,指的是我调用startActivity(Intent)的地方:

`05-17 01:40:37.918: E/AndroidRuntime(12997):android.content.ActivityNotFoundException: 
Unable to find explicit activity class {/com.rhombi.Menu}; have you declared 
this activity in your AndroidManifest.xml?

这是我在 com.rhombi.Intro 中使用 startActivity(Intent) 的方法:

startActivity(iMenu);

这是我之前在同一个类中声明它的方式:

public Intent iMenu = new Intent(this, Menu.class);

这是我在清单中声明所有内容的方式:

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    <activity
        android:name=".Intro"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Menu"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
    </activity>
</application>
</manifest>

我已经搜索了很多关于此的其他问题,但我似乎无法弄清楚问题所在。使我的问题与众不同的一件事是,当它告诉我它无法找到明确的活动类(“{/com.rhombi.Menu}”)时,那个小斜杠。这从未出现在我的搜索中,但我似乎做的一切都是正确的。

【问题讨论】:

  • 名为Menu的Activity拼写是否正确,是否存在于同一个包com.rhombi中?
  • 已在清单中注册您的活动?
  • @ДмитрийИвановичМенделеев 是的操作有&lt;activity android:name=".Menu"
  • 是的,该类以 com.rhombi.Menu 的形式存在。
  • 看起来可疑的是ComponentInfo 中的包名在这里是空的:{/com.rhombi.Menu} - 只有类名。您作为Context 传递给Intent ctor 的this 是什么?

标签: java android android-intent android-activity logcat


【解决方案1】:

您作为 Context 传递给 Intent 构造函数的 this 有问题,ComponentInfo {/com.rhombi.Menu} 中的空包名称证明了这一点 - 只有类名。

【讨论】:

    【解决方案2】:

    尝试改变

    android:name=".Menu"android:name="{package name}.Menu"

    【讨论】:

    • 我已经尝试过了,并且摆脱了经期。它没有用。
    • @JohnO。尝试清理和构建并发布Menu.java。好像还可以
    • 您的 android 应用程序将包含 2 个 androidManifest.xml,1 个在 bin 文件夹内,1 个在外部 ..希望您不要修改 bin 文件夹内的 androidmanifest.xml ..验证一次..因为一切看起来都不错这里..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    • 2013-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多