启动应用程序后出现 ClassNotFoundException
ClassNotFoundException after starting app
启动我的应用程序时我得到这个 LogCat:
09-22 18:07:04.487: E/AndroidRuntime(16352): FATAL EXCEPTION: main
09-22 18:07:04.487: E/AndroidRuntime(16352): Process: com.ip.whatsmyip.dl, PID: 16352
09-22 18:07:04.487: E/AndroidRuntime(16352): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ip.whatsmyip.dl/com.ip.whatsmyip.dl.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.ip.whatsmyip.dl.MainActivity" on path: DexPathList[[zip file "/data/app/com.ip.whatsmyip.dl-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2216)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2367)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.access0(ActivityThread.java:148)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.os.Handler.dispatchMessage(Handler.java:102)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.os.Looper.loop(Looper.java:135)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.main(ActivityThread.java:5274)
09-22 18:07:04.487: E/AndroidRuntime(16352): at java.lang.reflect.Method.invoke(Native Method)
09-22 18:07:04.487: E/AndroidRuntime(16352): at java.lang.reflect.Method.invoke(Method.java:372)
09-22 18:07:04.487: E/AndroidRuntime(16352): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
09-22 18:07:04.487: E/AndroidRuntime(16352): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
09-22 18:07:04.487: E/AndroidRuntime(16352): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ip.whatsmyip.dl.MainActivity" on path: DexPathList[[zip file "/data/app/com.ip.whatsmyip.dl-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-22 18:07:04.487: E/AndroidRuntime(16352): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-22 18:07:04.487: E/AndroidRuntime(16352): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2206)
09-22 18:07:04.487: E/AndroidRuntime(16352): ... 10 more
09-22 18:07:04.487: E/AndroidRuntime(16352): Suppressed: java.lang.NoClassDefFoundError: com.ip.whatsmyip.dl.MainActivity
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.DexFile.defineClassNative(Native Method)
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.DexFile.defineClass(DexFile.java:226)
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
09-22 18:07:04.487: E/AndroidRuntime(16352): ... 14 more
09-22 18:07:04.487: E/AndroidRuntime(16352): Suppressed: java.lang.ClassNotFoundException: com.ip.whatsmyip.dl.MainActivity
我没有发布代码,因为我知道它不会因为代码而发生。
有什么想法吗?
P.S:
我在扩展 AppCompatActivity
时遇到了一些问题,这让我通过 File - Import on eclipse 对应用程序进行了一些导入。
编辑
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ip.whatsmyip.dl"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE" >
</uses-permission>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
经过 MD 和 Aakash 的大量努力,我们决定从 eclipse 中删除此应用程序并复制粘贴代码。
这很有帮助。
谢谢大家。
启动我的应用程序时我得到这个 LogCat:
09-22 18:07:04.487: E/AndroidRuntime(16352): FATAL EXCEPTION: main
09-22 18:07:04.487: E/AndroidRuntime(16352): Process: com.ip.whatsmyip.dl, PID: 16352
09-22 18:07:04.487: E/AndroidRuntime(16352): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ip.whatsmyip.dl/com.ip.whatsmyip.dl.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.ip.whatsmyip.dl.MainActivity" on path: DexPathList[[zip file "/data/app/com.ip.whatsmyip.dl-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2216)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2367)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.access0(ActivityThread.java:148)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.os.Handler.dispatchMessage(Handler.java:102)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.os.Looper.loop(Looper.java:135)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.main(ActivityThread.java:5274)
09-22 18:07:04.487: E/AndroidRuntime(16352): at java.lang.reflect.Method.invoke(Native Method)
09-22 18:07:04.487: E/AndroidRuntime(16352): at java.lang.reflect.Method.invoke(Method.java:372)
09-22 18:07:04.487: E/AndroidRuntime(16352): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
09-22 18:07:04.487: E/AndroidRuntime(16352): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
09-22 18:07:04.487: E/AndroidRuntime(16352): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ip.whatsmyip.dl.MainActivity" on path: DexPathList[[zip file "/data/app/com.ip.whatsmyip.dl-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-22 18:07:04.487: E/AndroidRuntime(16352): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-22 18:07:04.487: E/AndroidRuntime(16352): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
09-22 18:07:04.487: E/AndroidRuntime(16352): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2206)
09-22 18:07:04.487: E/AndroidRuntime(16352): ... 10 more
09-22 18:07:04.487: E/AndroidRuntime(16352): Suppressed: java.lang.NoClassDefFoundError: com.ip.whatsmyip.dl.MainActivity
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.DexFile.defineClassNative(Native Method)
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.DexFile.defineClass(DexFile.java:226)
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
09-22 18:07:04.487: E/AndroidRuntime(16352): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
09-22 18:07:04.487: E/AndroidRuntime(16352): ... 14 more
09-22 18:07:04.487: E/AndroidRuntime(16352): Suppressed: java.lang.ClassNotFoundException: com.ip.whatsmyip.dl.MainActivity
我没有发布代码,因为我知道它不会因为代码而发生。
有什么想法吗?
P.S:
我在扩展 AppCompatActivity
时遇到了一些问题,这让我通过 File - Import on eclipse 对应用程序进行了一些导入。
编辑 AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ip.whatsmyip.dl"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE" >
</uses-permission>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
经过 MD 和 Aakash 的大量努力,我们决定从 eclipse 中删除此应用程序并复制粘贴代码。 这很有帮助。
谢谢大家。