ActivityNotFoundException(是的,此活动在 AndroidManifest.xml 中声明)
我发现一些线程报告了类似的问题,但没有一个< /a> 确实提供了一些我还没有尝试过的东西。
一个无辜的这样的调用:
mActivity.startActivity(new Intent(mActivity, MyEditPreferences.class));
在 AndroidManifest.xml 中使用以下内容:
<application>
<activity android:name="MyActivityLib" />
<activity android:name="com.example.baseapp.MyEditPreferences" android:label="@string/app_name">
</activity>
</application>
触发以下异常:
06-14 14:06:50.297: ERROR/AndroidRuntime(9272):
android.content.ActivityNotFoundException: Unable to find explicit activity class
{com.example.baseapp.paypal/com.example.baseapp.MyEditPreferences};
have you declared this activity in your AndroidManifest.xml?
事实是,在我将其从单一应用程序项目更改为由库项目组成的由两部分组成的项目之前,此代码曾经完美地工作和一个应用程序项目。
AndroidManifest.xml 是library 项目中的一个。
我需要做什么来消除这个 ActivityNotFoundException
?
I found a few threads reporting a similar problem but none of them really offers something that I haven't tried already.
An innocent such call:
mActivity.startActivity(new Intent(mActivity, MyEditPreferences.class));
with the following in AndroidManifest.xml:
<application>
<activity android:name="MyActivityLib" />
<activity android:name="com.example.baseapp.MyEditPreferences" android:label="@string/app_name">
</activity>
</application>
Triggers the following exception:
06-14 14:06:50.297: ERROR/AndroidRuntime(9272):
android.content.ActivityNotFoundException: Unable to find explicit activity class
{com.example.baseapp.paypal/com.example.baseapp.MyEditPreferences};
have you declared this activity in your AndroidManifest.xml?
The things is, this code used to work flawlessly before I changed it from a monolithic application project to a 2-part project that is comprised from a Library Project and an Application Project.
The AndroidManifest.xml is the one in the library project.
What do I need to do eliminate this ActivityNotFoundException
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我刚刚解决了这个问题。
我所要做的就是将 FQN 添加到 Application 项目的
AndroidManifest.xml
中:事实上,我删除了
MyEditPreferences
中的任何引用。 strong>Library 项目的AndroidManifest.xml
完全正确,并且仍然有效。它也适用于原始的 startActivity 1 行语句:
结论:重要的是应用程序的 AndroidManifest.xml,而不是库的。
I just solved the problem.
All I had to do was add the FQN to the Application project's
AndroidManifest.xml
:In fact, I removed any reference to
MyEditPreferences
in the Library project'sAndroidManifest.xml
completely and it still works.It also works with the original startActivity 1-line statement:
Conclusion: It's the application's
AndroidManifest.xml
that matters, not the library's.也许这会起作用?
Maybe this will work?
如果您使用的类名称包含在 android 包中(设置、首选项、活动等),则需要添加以下内容:
如果您不添加“name_of_your_package”,编译器会认为您正在引用android 包中的类 (android.*)。
If you use classes which names are included in an android package (Settings, Preferences, Activity, ...), you will need to put this:
If you don't put "name_of_your_package", the compiler will think that you are refering to the class in android package (android.*).
我知道这是一个非常古老的线程,但我也遇到了同样的问题。就我而言,我所要做的就是删除一个虚假的
I know this is a very old thread, but I've just had the same problem. In my case all I had to do was to delete a spurious
只需检查清单中是否有 IDE 未指出的错误即可。
Just check your manifest for errors that your IDE not pointed.