无法实例化应用 - ClassNotFoundException的 [英] unable to instantiate application - ClassNotFoundException

查看:148
本文介绍了无法实例化应用 - ClassNotFoundException的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:这个问题尚未在其他建议的SO问题解决

我有一个在市场上全面工作应用了一年多,除了极少数的崩溃报告。然后最近我改变了我的应用程序到库中,因此,它可以被包含在多个不同的包装的项目。这是如此,我可以很容易地做出不同的版本 - 免费,付费,非谷歌的市场,有/无在应用程序内购买等等等等

I had a fully working app on the market for over a year, with very few crash reports. Then recently I changed my app into a library, so that it could be included within multiple different "wrapper" projects. This was so that I could easily make different version - free, paid, non-google markets, with/without in-app purchasing etc etc.

新的图书馆+包装应用程序似乎很好地工作。我可以运行它多次,而不会出现错误。但随后一天后(当presumably操作系统已经关闭了一些应用程序的活动或全部)我试图运行它,它报道

The new "library+wrapper" app appeared to work fine. I could run it multiple times, without error. But then a day later (when presumably the OS had closed some or all of the app's activities) I tried to run it and it reported

Unable to instantiate application com.mycompany.mygamelibrary.MyGameApplicationClass: java.lang.ClassNotFoundException: com.mycompany.mygamelibrary.MyGameApplicationClass

未能找到类是,当程序启动运行的第一类,MyGameApplicationClass - 它扩展应用程序。这个类是库的一部分。

The class it failed to find is the first class that runs when the program starts up, MyGameApplicationClass - which extends Application. This class is part of the library.

我怀疑,在两个清单文件中的一个愚蠢的事情。

I suspect something goofy in one of the two manifest files.

包装的明显项目包含的行...

The manifest of the wrapper project contains the lines...

<application android:icon="@drawable/mygame_icon"
    android:screenOrientation="portrait" android:label="My Game Name"
    android:name="com.mycompany.mygamelibrary.MyGameApplicationClass">

任何想法可能已经错了?

Any ideas what could have gone wrong?

编辑:库被引用的正确的方式通过yorkw的回答<一个定义href="http://stackoverflow.com/questions/10866431/android-activity-classnotfoundexception-tried-everything/10965393#10965393">this SO质疑。

The library was referenced "the correct way" as defined by yorkw's answer to this SO question.

编辑:此刻我不能重复崩溃:-(我不知道它是什么操作系统并当应用程序不使用一两天。

I can not repeat the crash at the moment :-( I don't know what it is the OS does when the app is not used for a day or two.

推荐答案

有两种可能性。要么你和我一样,在你的manifest文件拼写错误。有同事或朋友阅读,以确保该名称是正确的。或者你还没有引用该项目正常。

There are two possibilities. Either you, like me, have a spelling error in your manifest file. Have a co-worker or friend read it to make sure the name is correct. Or you have not referenced the project correctly.

官方文档介绍了如何正确地在它的文档

The official document describes how to properly link projects in its documentation.

为什么它会首先似乎工作,后来停止工作是一个有点神秘。不过,我想,如果VM可能仍不得不准备解决的类在库就好了必要的参考。虚拟机的重启删除了所有这些引用,并试图解决这些问题是不成功的。

Why it would first seem to work and later stop working is a bit of a mystery. However, I guess that the VM might still have had the necessary references ready to resolve the classes in the library just fine. A restart of the VM removed all those references and trying to resolve them was unsuccessful.

更新:关于在OP的编辑:当你确认你已经正确地引用了另一个项目,你可以检查的项目包括在APK,只是要确定。您可以重命名,然后打开一个APK的任何其它归档(.rar程序为我工作得很好)。有时,它发生在我身上,这个项目是不正确包含在APK。您的工作空间进行清洁救济的问题,因此可能你的IDE取决于你所使用的重新启动。为了例如手动进行一次大扫除在Eclipse中使用项目 - &GT;清洁... 或尝试 Android的工具 - &GT;修复项目属性通过在你的项目上右击。

Update: Regarding the edits in the OP: As you confirm that you have correctly referenced the other project, you can check if the project is included in APK, just to be sure. You can rename and open an APK as any other archive (.rar works fine for me). Sometimes, it happened to me, the project is not correctly included in the APK. A cleaning of your workspace usually remedies the problem and so could a restart of your IDE depending on what you are using. To manually conduct a clean in Eclipse for example, use Project->Clean... or try Android Tools->Fix Project Properties by right-clicking on your project.

你似乎也已经被重新启动设备解决了问题,这可能是因为该图书馆有联系不正确。一个问题,我从来没有见过自己,但作为一个非常普遍的报价说:?您是否尝试过将其关闭并重新打开

As you seem to also have fixed the problem by restarting your device, it could be that the libraries were linked incorrectly. A problem that I have never seen myself but as a very common quote says: "Have you tried turning it off and on again?".

这篇关于无法实例化应用 - ClassNotFoundException的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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