我有一个使用OI FileManager的测试项目。我将该项目作为 Android 库添加到我的测试项目中,然后在库中调用 Activity。它显示错误:
E/AndroidRuntime( 1359): FATAL EXCEPTION: main
E/AndroidRuntime( 1359): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.filemanager.FileManagerActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1359): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
E/AndroidRuntime( 1359): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
E/AndroidRuntime( 1359): at android.app.Activity.startActivityForResult(Activity.java:2817)
E/AndroidRuntime( 1359): at android.app.Activity.startActivity(Activity.java:2923)
E/AndroidRuntime( 1359): at com.androidcoretest.FileExplorerTest$1.onClick(FileExplorerTest.java:24)
E/AndroidRuntime( 1359): at android.view.View.performClick(View.java:2408)
E/AndroidRuntime( 1359): at android.view.View$PerformClick.run(View.java:8816)
E/AndroidRuntime( 1359): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 1359): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1359): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1359): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 1359): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1359): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1359): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 1359): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 1359): at dalvik.system.NativeStart.main(Native Method)
当我在清单中添加该活动的完整路径时,它会产生另一个错误。
<activity
android:label="@string/app_name"
android:name="org.openintents.filemanager.FileManagerActivity" >
</activity>
表明:
E/AndroidRuntime( 1393): FATAL EXCEPTION: main
E/AndroidRuntime( 1393): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidcoretest/org.openintents.filemanager.FileManagerActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.distribution.EulaActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 1393): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 1393): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 1393): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 1393): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1393): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1393): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 1393): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1393): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 1393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 1393): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1393): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.distribution.EulaActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1393): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
E/AndroidRuntime( 1393): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
E/AndroidRuntime( 1393): at android.app.Activity.startActivityForResult(Activity.java:2817)
E/AndroidRuntime( 1393): at android.app.Activity.startActivity(Activity.java:2923)
E/AndroidRuntime( 1393): at org.openintents.distribution.EulaOrNewVersion.startForwardActivity(EulaOrNewVersion.java:127)
E/AndroidRuntime( 1393): at org.openintents.distribution.EulaOrNewVersion.showEula(EulaOrNewVersion.java:69)
E/AndroidRuntime( 1393): at org.openintents.distribution.DistributionLibrary.showEulaOrNewVersion(DistributionLibrary.java:53)
E/AndroidRuntime( 1393): at org.openintents.filemanager.FileManagerActivity.onCreate(FileManagerActivity.java:312)
E/AndroidRuntime( 1393): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 1393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 1393): ... 11 more
W/ActivityManager( 59): Force finishing activity com.androidcoretest/org.openintents.filemanager.FileManagerActivity
我会说这是 Eclipse 的一个错误。Eclipse 和 ADT 最近在构建过程中有很多错误:ClassNotFound 和 ActivityNotFound。
更新:我的代码只使用一行:
final Intent intent = new Intent(FileExplorerTest.this, FileManagerActivity.class);
startActivity(intent);
其实我有3个项目。2个图书馆项目和1个测试项目。库“OI File Manager”使用库“OI Distribution”,然后测试项目C使用库“IO File Manager”。