Class NotFoundException after updating ADT

I recently updated the Android SDK and Eclipse ADT to the latest version. Now when I try to run an existing Android project, LogCat shows a ClassNotFoundException .

I tried to create a new device, but the problem still exists.

manifest

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.myapp.MainActivity" android:label="@string/app_name" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> 

Logcat

 05-17 13:09:56.357: E/AndroidRuntime(969): FATAL EXCEPTION: main 05-17 13:09:56.357: E/AndroidRuntime(969): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myapp/com.example.myapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.myapp.MainActivity" on path: /data/app/com.example.myapp-1.apk 05-17 13:09:56.357: E/AndroidRuntime(969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106) 05-17 13:09:56.357: E/AndroidRuntime(969): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 05-17 13:09:56.357: E/AndroidRuntime(969): at android.app.ActivityThread.access$600(ActivityThread.java:141) 05-17 13:09:56.357: E/AndroidRuntime(969): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 05-17 13:09:56.357: E/AndroidRuntime(969): at android.os.Handler.dispatchMessage(Handler.java:99) 05-17 13:09:56.357: E/AndroidRuntime(969): at android.os.Looper.loop(Looper.java:137) 05-17 13:09:56.357: E/AndroidRuntime(969): at android.app.ActivityThread.main(ActivityThread.java:5041) 05-17 13:09:56.357: E/AndroidRuntime(969): at java.lang.reflect.Method.invokeNative(Native Method) 05-17 13:09:56.357: E/AndroidRuntime(969): at java.lang.reflect.Method.invoke(Method.java:511) 05-17 13:09:56.357: E/AndroidRuntime(969): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 05-17 13:09:56.357: E/AndroidRuntime(969): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 05-17 13:09:56.357: E/AndroidRuntime(969): at dalvik.system.NativeStart.main(Native Method) 05-17 13:09:56.357: E/AndroidRuntime(969): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.myapp.MainActivity" on path: /data/app/com.example.myapp-1.apk 05-17 13:09:56.357: E/AndroidRuntime(969): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65) 05-17 13:09:56.357: E/AndroidRuntime(969): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 05-17 13:09:56.357: E/AndroidRuntime(969): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 05-17 13:09:56.357: E/AndroidRuntime(969): at android.app.Instrumentation.newActivity(Instrumentation.java:1054) 05-17 13:09:56.357: E/AndroidRuntime(969): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 05-17 13:09:56.357: E/AndroidRuntime(969): ... 11 more 

I noticed that the new APK file is called myapp-1.apk , while it was usually called myapp.apk . Can someone tell me how to fix it?

+59
android eclipse adt
May 17 '13 at 13:22
source share
4 answers

Try to execute Project → Properties → Java build path → Order and Export and make sure that Android Private Libraries are checked for your project and for all other library projects you use. After that, clear all projects and see what happens.

+137
May 17 '13 at 13:25
source share

I know that it is very late to write the answer here. The workaround mentioned by Krauxe didn't help me. My project has two library projects and two banks. I found the solution posted by "laaptu" on the Library page is not added to the APK after upgrading to ADT 22 .

+1
Jul 24. '13 at 11:53 on
source share

I have an Eclipse ADT bundle and an additional @Krauxe answer updating the Eclipse.project file as shown below:

 <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>RedbeaconPro</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>com.android.ide.eclipse.adt.ApkBuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> 
+1
Jan 02 '14 at
source share

If you use the Maven plugin in your project, "Maven → Maven Update ..." may cause the same problem as a ClassNotFoundException. As you know, the default class output folder should be / bin / classes, which is specified in the .classpath and Eclipse Build Path files. But as soon as you do "Maven-> Maven Update ...", the output folder will be set as "target / classes". You can find it (output = "target / classes") in your .classpath file.

.classpath:

 ... <classpath> <classpathentry kind="src" path="gen"/> <classpathentry kind="src" output="target/classes" path="src/main/java"> ... 

How to solve this problem , I explicitly specify the output folder of the classes as "bin / classes" in the pom.xml file .

Pom.xml file:

 ... <build> <sourceDirectory>src/main/java</sourceDirectory> <outputDirectory>bin/classes</outputDirectory> ... 
0
Jul 19 '14 at 4:05
source share



All Articles