问题
When starting my app i get this 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.access$800(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
I'm not posting the code because i know it's not happening because of the code.
Any idea?
P.S:
I had some problems with extending AppCompatActivity
which made me do some imports to the app through File - Import on eclipse.
EDIT 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>
回答1:
After a lot of effort from MD and Aakash we decided to delete this application from eclipse and copy paste the code. And it helped.
Thanks guys.
来源:https://stackoverflow.com/questions/32720679/classnotfoundexception-after-starting-app