机器人部队密切:ClassNotFoundException异常的活动类 [英] android force close: ClassNotFoundException for Activity class

查看:172
本文介绍了机器人部队密切:ClassNotFoundException异常的活动类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始我的(即将成为)安卓游戏(从日食)它打开,但立刻强行关闭。

When I start my (soon-to-be) android game (from eclipse) it opens, but immediately force-closes.

LogCat中说:

07-09 17:12:35.709: ERROR/AndroidRuntime(3866): Uncaught handler: thread main exiting due to uncaught exception
07-09 17:12:35.719: ERROR/AndroidRuntime(3866): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.anselm.eickhoff.rhythm/org.anselm.eickhoff.rhythm.RhythmGameActivity}: java.lang.ClassNotFoundException: org.anselm.eickhoff.rhythm.RhythmGameActivity in loader dalvik.system.PathClassLoader@4001e740
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2497)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.app.ActivityThread.access$2200(ActivityThread.java:126)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.os.Looper.loop(Looper.java:123)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.app.ActivityThread.main(ActivityThread.java:4595)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at java.lang.reflect.Method.invokeNative(Native Method)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at java.lang.reflect.Method.invoke(Method.java:521)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at dalvik.system.NativeStart.main(Native Method)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866): Caused by: java.lang.ClassNotFoundException: org.anselm.eickhoff.rhythm.RhythmGameActivity in loader dalvik.system.PathClassLoader@4001e740
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2489)
07-09 17:12:35.719: ERROR/AndroidRuntime(3866):     ... 11 more

在这里有趣的行是(我认为):

the interesting line here is (I think):

07-09 17:12:35.719: ERROR/AndroidRuntime(3866): Caused by: java.lang.ClassNotFoundException: org.anselm.eickhoff.rhythm.RhythmGameActivity in loader dalvik.system.PathClassLoader@4001e740

这让我吃惊,因为我有这个类(在正确的软件包)

Which surprises me, because I have this class (in the right package)

编辑:的澄清,添加的第一线,我省略了(加上进口)

edit: to clarify, added the first line which I had omitted (together with the imports)

package org.anselm.eickhoff.rhythm;
...
public class RhythmGameActivity extends Activity {


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

    @Override
    public void onPause() {
    }
}

而这一切确实!

and that's all it does!

我也注册它在清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.anselm.eickhoff.rhythm"
      android:versionCode="1" android:versionName="pre-alpha">

    <uses-permission android:name="android.permission.INTERNET" />
    <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true" android:hasCode="false">

    <activity android:name=".RhythmGameActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    </application>

</manifest> 

编辑:的这一切已经开始了,因为我改名为活动从RhythmGame到RhythmGameActivity,但我pretty的肯定,我更换了所有所以也许它仍然是错误chached地方引用? (我试过刷新和清洗项目)

edit: this all has started since I renamed the activity from RhythmGame to RhythmGameActivity, but I am pretty sure I replaced all the references so maybe it is still wrongly chached somewhere? (I tried refreshing and cleaning the project)

您的帮助实在是AP preciated - IM卡

Your help is really appreciated - im stuck!

推荐答案

我使用Perforce公司与Eclipse和已经发现,在根据源代码控制只读原因,所有文件的Perforce公司的默认行为,建立一个没有明确规定的问题Eclipse的建立窗口。此外,似乎有添加库项目中,即使的.classpath和.project文件是可写的库可能无法正常自身与该项目相关联的时候是一个怪癖我。我一般按照下列步骤为解决这种性质的错误(假定该项目的清单是正确的):

I use Perforce with Eclipse and have discovered that Perforce's default behavior of making all files under source control read-only causes build problems that aren't clearly specified in Eclipse's build window. Also, there seems to be a quirk for me when adding a library project where even if the .classpath and .project file are writable the library may not properly associate itself with the project. I generally follow these steps for resolving errors of this nature (this assumes that the project's manifest is correct):

1)关闭的Eclipse。 Eclipse中可以缓存有关文件的读/写状态的一些信息。

1) Close Eclipse. Eclipse may cache some info about a file's R/W status.

2)(宽中风)从源头控制检查出来进行所有项目的可写文件或者,也可以通过操作系统。的.classpath和.project在最低限度应该是可写的。

2) (Broad stroke) Make all of the files in the project writable either by checking them out from source control, or through the OS. .classpath and .project at the bare minimum should be writable.

2.5),如果放置在生成过程中产生的,并且是Android的构建过程中,就应该从源头控制取出的正常组成部分,可写在源代码控制文件。包括但不限于的.class文件,并在bin和根目录。

2.5) If you placed files under source control that are generated during the build process and are a normal part of the Android build process then they should be removed from source control and made writable. Including but not limited to .class and files in the bin and gen directories.

3)在Eclipse中打开项目。如果没有错误的问题可以是固定的。

3) Open the project in Eclipse. If there are no errors the problem may be fixed.

4)检查项目的探险家和寻找专门为库项目的依赖,可能会丢失。在我的经验,看到所有的lib项目的目录,并在项目中的资源管理器层次结构中的库状态图标是非常重要的。如果一个lib项目文件夹和图标丢失,去​​属性 - > Android和选择,并添加缺少的LIB(S)。添加一个lib后选择应用一表工程资源管理器,以确保该LIB图标出现在项目目录。这一步的解释似乎过于详细,但我一直咬了几次强迫自己在这里要格外细心了。如果一个lib不会增加,尝试添加其他的虚拟LIB项目,并在您需要的lib组合中取出。不是开玩笑 - 这有时是必要的,我

4) Examine the project explorer and look specifically for library project dependencies that may be missing. In my experience it's important to see all lib projects' directories and their library status icon in your project's explorer hierarchy. If a lib project folder and icon is missing, go to Properties->Android and select and add the missing lib(s). After adding a lib select "Apply" an watch the project explorer to make sure that the lib icon appears in the project directory. This step explanation may seem overly detailed, but I've been bitten several times before forcing myself to be extra observant here. If a lib won't add, try adding other dummy lib project and removing them in combination with the lib you want. No joke - this is sometimes necessary for me.

5)清洁所有的项目。

5) Clean all of the projects.

6)读取错误列表并解决任何其他错误。

6) Read the error list and resolve any other errors.

7)修复所有的警告,你一直在拖延修复。

7) Fix all of the warnings you've been putting off fixing.

8)(不是必须的,但重要的)恢复所有未更改的文件,并观察什么留在你修改列表 - 这些都是需要你注意在未来的prevent建设问题的文件

8) (Not essential but important) Revert all unchanged files and observe what's left in you changelist - these are the files that will need your attention in the future to prevent build problems.

这篇关于机器人部队密切:ClassNotFoundException异常的活动类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆