【问题标题】:android (exception ActityNotFoundException)安卓(异常 ActityNotFoundException)
【发布时间】:2011-04-18 19:32:26
【问题描述】:

我正在开发一款安卓游戏https://code.google.com/p/something-soft/,我的日志猫说它正在尝试触发游戏的意图,但随后主线程似乎死了(带有 ActivityNotFoundException 异常),然后似乎冻结了。

在代码库中,我已经提交了除 /bin 之外的所有文件...包括最近的 logcat 输出(/trunk/KingLand/log.txt)和调试器输出(/trunk/KingLnad/debug.txt)

我正在运行的模拟器是具有 2024MiB 内存的 Android 平台 2.1-update1,如果这真的会导致任何问题(我不确定)

我们将不胜感激。

编辑:AndroidManifest.xml

$<?xml version="1.0" encoding="utf-8"?>
$  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
$        package="android.app"
$        android:versionCode="1"
$        android:versionName="1.0">
$        <application android:icon="@drawable/icon" android:label="@string/app_name">
$        <activity android:name="com.Something.Soft.KingsLand"
$                    android:label="@string/app_name">
$             <intent-filter>
$                   <action android:name="android.intent.action.MAIN" />
$                   <category android:name="android.intent.category.LAUNCHER" />
$             </intent-filter>
$        </activity>
$        <activity android:name=".Tutorial"
$              android:label="@string/tutorial"
$              android:theme="@android:style/Theme.Dialog"/>
$        <activity android:name=".Prefs"
$              android:label="@string/settingsTitle"/>
$        <activity android:name=".Game"     // this is the where the intent should fire to
$              android:label="@string/gameTitle"/>
$        </application>
$</manifest> 

【问题讨论】:

  • 清单文件中是否定义了Intent?
  • Activity是否定义在AndroidManifest.xml中?
  • 是的,包含在清单中。问题现在包含清单
  • MisterSquonk:没有这个变化仍然会导致主线程到达相同的异常

标签: android activitynotfoundexception


【解决方案1】:

package 属性应该是您的活动所在的包。

在您的 AndroidManifest.XML 中,清单标签应在属性包上声明您的活动所在的包。

它将是:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.Something.Soft"
    android:versionCode="1"
    android:versionName="1.0">
 //The others attributes.

您定义了:“package="android.app"" 并且您的 Activity 位于 com.Something.Soft

您还应该遵守代码约定,包名完全小写。

【讨论】:

  • 在什么文件中("package="android.app" 到 "package="com.Something.Soft")因为我没有找到而需要更改
  • 谢谢:有一次我通过(右键单击项目>android工具>重命名应用程序包)更改了包名称,我猜它并没有改变一切
【解决方案2】:

您的套餐因活动而异。假设“com.Something.Soft”。包是您的游戏活动所在的位置,请将 package="android.app" 更改为 package="com.Something.Soft"

您也可以明确拼出定义活动的全名,即&lt;activity android:name="com.Something.Soft.Game"

【讨论】:

  • 这是什么文件("package="android.app" 到 "package="com.Something.Soft")因为我没有找到而需要更改
  • AndroidManifest.xml 上面的第 3 行。
猜你喜欢
  • 2015-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多