无法实例化活动ComponentInfo实例、ComponentInfo

2023-09-13 01:39:26 作者:心野套路深

我开发的Froyo的最低版本和姜饼作为目标版本的应用程序。因此,清单显示:

I am developing an application for Froyo as minimum version and Gingerbread as the target version. So, the manifest shows:

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

我有一个模拟器和Nexus One的姜饼,应用程序部署和安装正确。 但是,当它启动时,它崩溃,并扔在日志中的错误是:

I have an emulator and a Nexus One with Gingerbread, and the application deploys and installs correctly. But when it starts, it crashes, and the error thrown in the log is:

09-18 06:35:11.240: ERROR/AndroidRuntime(382): FATAL EXCEPTION: main
09-18 06:35:11.240: ERROR/AndroidRuntime(382): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.my.package/com.my.package.Dashboard}: java.lang.ClassNotFoundException: com.my.package.Dashboard in loader dalvik.system.PathClassLoader[/data/app/com.my.package-2.apk]
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.os.Looper.loop(Looper.java:130)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.app.ActivityThread.main(ActivityThread.java:3683)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at java.lang.reflect.Method.invokeNative(Native Method)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at java.lang.reflect.Method.invoke(Method.java:507)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at dalvik.system.NativeStart.main(Native Method)
09-18 06:35:11.240: ERROR/AndroidRuntime(382): Caused by: java.lang.ClassNotFoundException: com.my.package.Dashboard in loader dalvik.system.PathClassLoader[/data/app/com.my.package-2.apk]
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
09-18 06:35:11.240: ERROR/AndroidRuntime(382):     ... 11 more

是的,活动的仪表板在清单中声明:

And yes, the activity "Dashboard" is declared in the Manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.my.package"
      android:versionCode="1"
      android:versionName="1.0"
      android:installLocation="auto">

      <activity android:name=".Dashboard"
              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>

      ...

那么可以在此问题涉及到?这是推动我疯了。

So what can this problem be related to?? This is driving me nuts.

推荐答案

事实证明,该项目文件中缺少一些必需的APK建设者要正确。这就是为什么它是不是能够找到仪表板类。

As it turns out, the project files were missing some of the builders required for the apk to be correctly made. That's why it was not able to find the Dashboard class.

解决方案是创建一个空的Andr​​oid项目,并比较了自动生成的.project和.properties文件与那些在你受伤的项目。

The solution is to create an empty Android project and compare the automatically generated .project and .properties files with the ones in your broken project.

 
精彩推荐
图片推荐