ClassNotFoundException的上课的时候有没有? [英] ClassNotFoundException when the class is there?
问题描述
我有点坚持这一点。 Android是抛出一个的ClassNotFoundException
即使有这样一类。
I'm a bit stuck on this. Android is throwing a ClassNotFoundException
even though there is such a class.
04-20 09:07:50.179: E/AndroidRuntime(525): FATAL EXCEPTION: main
04-20 09:07:50.179: E/AndroidRuntime(525): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.company.app/com.company.app.Main}: java.lang.ClassNotFoundException: com.company.app.Main
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.os.Looper.loop(Looper.java:137)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-20 09:07:50.179: E/AndroidRuntime(525): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 09:07:50.179: E/AndroidRuntime(525): at java.lang.reflect.Method.invoke(Method.java:511)
04-20 09:07:50.179: E/AndroidRuntime(525): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-20 09:07:50.179: E/AndroidRuntime(525): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-20 09:07:50.179: E/AndroidRuntime(525): at dalvik.system.NativeStart.main(Native Method)
04-20 09:07:50.179: E/AndroidRuntime(525): Caused by: java.lang.ClassNotFoundException: com.company.app.Main
04-20 09:07:50.179: E/AndroidRuntime(525): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-20 09:07:50.179: E/AndroidRuntime(525): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-20 09:07:50.179: E/AndroidRuntime(525): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
04-20 09:07:50.179: E/AndroidRuntime(525): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
04-20 09:07:50.179: E/AndroidRuntime(525): ... 11 more
有这样叫主
A类 Main.java
。
公共类主要扩展FragmentActivity
这是在包 com.company.app </ code>。
public class Main extends FragmentActivity
which is in the package com.company.app
.
这是以前的工作,但是当我回到今天的应用工作,它只是停止工作。我不知道发生了什么。
It was working before but when I went back to work on the app today it just stopped working. I don't know what happened.
这是在清单中正确定义。
It is defined correctly in the Manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light" >
<activity
android:label="@string/app_name"
android:name=".Main" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
几件事我已经试过:
- 重新启动Eclipse的
- 重新启动模拟器
- 卸载并重新安装应用程序在模拟器中
- 清洁项目。
- 检查是否
根
和的src
是来源
构建路径的标签。
- Restarting Eclipse
- Restarting the emulator
- Uninstalling and reinstalling the app in the emulator
- Cleaning the project.
- Checking if
gen
andsrc
is in theSource
tab of the build path.
因为它看起来现在,我可能会放弃目前的项目,并从头开始。
As it looks right now, I may have to abandon the current project and start from scratch.
任何帮助将是非常美联社preciated。
Any help would be much appreciated.
更新:
该应用程序工作,如果主
扩展活动
而不是 FragmentActivity
。也许是一些与Android的支持包?
The app works if Main
extends Activity
instead of FragmentActivity
. Perhaps it is something with the Android Support package?
更新2:
我是pretty肯定是。当我不使用的支持包,我用正常的片段
班的Android 3.0及以上版本,应用程序工作正常。
I'm pretty sure it is. When I don't use the support package and I use the normal Fragment
classes in Android 3.0 and up, the app works fine.
问题已经得到解决。 :)
The problem is now fixed. :)
由于某些原因,Android的支持包从删除自身在项目/库
目录,它是从外部位置引用它(工作区
目录)。
For some reason the Android support package removed itself from the /libs
directory in the project and it was referencing it from an external location (outside the workspace
directory).
我将迎来阿卜杜伊盖尔的第一个答案是正确的,他指示我在正确的轨道上。
I will mark Abdu Egal's first answer as correct as he directed me on the right track.
推荐答案
似乎没有在您的主要活动的OnCreate错误。你有没有提供的onCreate(捆绑savedInstance)如果是这样,请试着清除它,看看它是否工作呢。
It seems that there is an error in the onCreate of your main activity. Did you provide an onCreate(Bundle savedInstance) if so , try to clear it and see if it works then.
如果不工作,尝试使用扩展活动,而不是延长FrameActivity。
If that does not work, try to use extend Activity instead of extend FrameActivity.
好运气
这篇关于ClassNotFoundException的上课的时候有没有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!