当类肯定存在NoClassDefFound错误 [英] NoClassDefFound error when class definitely exists

查看:6058
本文介绍了当类肯定存在NoClassDefFound错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经工作了几个月,一个游戏,现在,突然遇到了问题。

I've been working on a game for a few months now, and have suddenly encountered a problem.

从昨天开始,我一直得到一个 NoClassDefFound 错误。目前还没有code的变化都没有。它是在晚上工作,而不是在上午。变化都没有。这里是确切的堆栈跟踪:

Since yesterday, I have been getting a NoClassDefFound error. There have been no code changes at all. It was working at night, and wasn't in the morning. No change at all. Here is the exact stacktrace:

06-23 23:12:19.746: E/ACRA(29146): Blue Boy fatal error : com.appaholics.blueboy.BlueBoy
06-23 23:12:19.746: E/ACRA(29146): java.lang.NoClassDefFoundError: com.appaholics.blueboy.BlueBoy
06-23 23:12:19.746: E/ACRA(29146):  at com.appaholics.blueboy.LoadingScreen.loadTextures(LoadingScreen.java:125)
06-23 23:12:19.746: E/ACRA(29146):  at com.appaholics.blueboy.LoadingScreen.load(LoadingScreen.java:85)
06-23 23:12:19.746: E/ACRA(29146):  at com.appaholics.blueboy.LoadingScreen.onCreate(LoadingScreen.java:40)
06-23 23:12:19.746: E/ACRA(29146):  at android.app.Activity.performCreate(Activity.java:4465)
06-23 23:12:19.746: E/ACRA(29146):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-23 23:12:19.746: E/ACRA(29146):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-23 23:12:19.746: E/ACRA(29146):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-23 23:12:19.746: E/ACRA(29146):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-23 23:12:19.746: E/ACRA(29146):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-23 23:12:19.746: E/ACRA(29146):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-23 23:12:19.746: E/ACRA(29146):  at android.os.Looper.loop(Looper.java:137)
06-23 23:12:19.746: E/ACRA(29146):  at android.app.ActivityThread.main(ActivityThread.java:4424)
06-23 23:12:19.746: E/ACRA(29146):  at java.lang.reflect.Method.invokeNative(Native Method)
06-23 23:12:19.746: E/ACRA(29146):  at java.lang.reflect.Method.invoke(Method.java:511)
06-23 23:12:19.746: E/ACRA(29146):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-23 23:12:19.746: E/ACRA(29146):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-23 23:12:19.746: E/ACRA(29146):  at dalvik.system.NativeStart.main(Native Method)

的方法,在其中发生异常:

The method in which the exception occurs:

        private void loadTextures() {
        BlueBoy.sTextures = new HashMap<String,TextureRegion>();
        BlueBoy.sTiledTextures = new HashMap<String,TiledTextureRegion>();
        BlueBoy.sTextureHolders = new ArrayList<Texture>();
        BlueBoy.sHitVoiceSounds = new Sound[4];
        BlueBoy.sHitSounds = new Sound[4];
        BlueBoy.sWinSounds = new Sound[8];
        BlueBoy.sLoseSounds = new Sound[4];     
        Texture texture;
        TextureRegionFactory.setAssetBasePath("gfx/");
        BufferObjectManager.setActiveInstance(new BufferObjectManager());
        }

不过,类BlueBoy肯定存在。要绝对保证,我已经采取措施来反编译自己的应用程序的 classes.dex 。我已反编译无论是在的apk本身同时使的apk生成与所述一个。类是在两人面前present。这也是present在 /斌/班/ COM / appaholics / blueboy / 。当反编译,我可以看到类的全部源代码,因为它应该是。

However, the class BlueBoy definitely exists. To make absolutely sure, I have taken to decompiling my own app's classes.dex. I have decompiled both the one generated while making the .apk and the on in the .apk itself. The class is present in both of them. It is also present in /bin/classes/com/appaholics/blueboy/. When decompiled, I can see the full source of the class, as it should be.

我已经尝试了所有我能想到的,在网络上找到解决它。我有:

I have tried everything I could think of and find on the net to fix it. I have:


  • 完成它创建一个干净

  • 从源头在Eclipse中创建一个新的项目

  • 创建一个新的项目,并手动换档一切,它

  • 试过重命名类

  • 试过重命名包

  • 试图通过命令行编译它

  • 尝试过在命令行中在清洁

所有工作区做工精细等项目。

All of the other projects in the workspace work fine.

其他类,如闪屏和装载的屏幕,在它面前BlueBoy做工精细的启动。 Android版可以找到他们。

Other classes like the splash screen and loading screen, which are launched before BlueBoy work fine. Android can find them.

没有任何人有任何想法,为什么会发生这种情况?类是因为我的存在,肯定存在,但Android的不同意。

Does anybody have any idea as to why this would happen? The class is exists as surely as I exist, but Android disagrees.

编辑:按照duffymo的建议下,我加入以下到我的闪屏检查这个类存在的类路径:

As per duffymo's suggestion, I check the class path for the existence of this class by adding the following to my splash screen:

       try {
          Class.forName("com.appaholics.blueboy.BlueBoy", false, null);
       } catch (ClassNotFoundException e1) {
          Log.d("ClassCheck", "Not found.");
          e1.printStackTrace();
       }

我得到的在LogCat中未找到消息。现在我们知道,类是不存在的类路径中,如何解决呢?类是在同一个包的闪屏和装载类,这两个都是present。这是什么原因一级不存在,我怎么能解决这个问题?

I get the Not Found message in the LogCat. Now that we know that the class isn't there in the classpath, how do I fix it? The class is in the same package as the splash screen and loading class, and both of those are present. What could cause this one class to not be there, and how could I fix it?

EDIT2:FWIW, System.getProperties(java.class.path); 的回报。

FWIW, System.getProperties("java.class.path"); returns ".".

推荐答案

我已经成功地解决它。这些都是我带的具体步骤:

I've managed to fix it. These are the exact steps I took:


  • 手动复制所有的内容到一个新的项目。不要使用该选项从现有源创建项目。

  • 转到项目属性,并从构建路径中删除的android.jar。

  • 保存

  • 回手动添加罐子,确保这是同一版本的Andr​​oid和以前一样。

它应该现在的工作。我试图在原有项目,其中一个我创建从它的源头上面两个步骤,他们没有工作。

It should work now. I tried the above steps on both the original project and one which I created from it's source, and they didn't work.

我不知道如何或为什么它的工作原理,但我知道它。 FWIW,我使用ADT 18日,SDK工具19和平台工具11。

I don't know how or why it works, but I know it does. FWIW, I'm using ADT 18, with SDK tools 19 and platform tools 11.

这篇关于当类肯定存在NoClassDefFound错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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