First of all, with a picture (print screen of my IDE) it would be more easy to show my packages and file but when I tried to submit my question, the system says "You need at least 10 reputation to post images" What does that mean ?????
I use Eclipse Juno with the ADT plugin from Google to develop Android application.
At first, no problem, I could run my app in the emulator and even on my Android device.
It is only after I have added the Eclipse plugin for Maven that the problems started. This is the plugin "Integration for the Android Development Tools and the m2eclipse Maven2 plugin ver 0.4.3 "
Since then, I've tried everything already spend too much time without being able to move forward.
At run time I get this exception:
01-10 09:56:17.804: E/Trace(1180): error opening trace file: No such file or directory (2)
01-10 09:56:17.914: D/AndroidRuntime(1180): Shutting down VM
01-10 09:56:17.914: W/dalvikvm(1180): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
01-10 09:56:17.935: E/AndroidRuntime(1180): FATAL EXCEPTION: main
01-10 09:56:17.935: E/AndroidRuntime(1180): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.shoppinglist2/com.example.shoppinglist2.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.shoppinglist2.MainActivity" on path: /data/app/com.example.shoppinglist2-1.apk
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.os.Looper.loop(Looper.java:137)
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.app.ActivityThread.main(ActivityThread.java:5041)
01-10 09:56:17.935: E/AndroidRuntime(1180): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 09:56:17.935: E/AndroidRuntime(1180): at java.lang.reflect.Method.invoke(Method.java:511)
01-10 09:56:17.935: E/AndroidRuntime(1180): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-10 09:56:17.935: E/AndroidRuntime(1180): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-10 09:56:17.935: E/AndroidRuntime(1180): at dalvik.system.NativeStart.main(Native Method)
01-10 09:56:17.935: E/AndroidRuntime(1180): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.shoppinglist2.MainActivity" on path: /data/app/com.example.shoppinglist2-1.apk
01-10 09:56:17.935: E/AndroidRuntime(1180): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
01-10 09:56:17.935: E/AndroidRuntime(1180): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-10 09:56:17.935: E/AndroidRuntime(1180): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
01-10 09:56:17.935: E/AndroidRuntime(1180): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
01-10 09:56:17.935: E/AndroidRuntime(1180): ... 11 more
If I could add a picture, you could see that there is no error in the package com.example.shoppinglist2 (from the package explorer view) and that the Class name is MainActivity.
Bellow the content of my AndroidManifest.xml file (the issue comes from activity android:name)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shoppinglist2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.example.shoppinglist2.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>
</manifest>
You are using Maven plugin in your project, "Maven -> Maven Update..." may cause the problem that ClassNotFoundException. As you know, the default classes output folder should be /bin/classes which is specified in .classpath file and Eclipse Build Path. But once you do "Maven->Maven Update...", the output folder would be set as "target/classes". You can find it(output="target/classes") in your .classpath file.
.classpath file:
...
<classpath>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
...
How to resolve this problem, please explicitly specify the classes output folder as "bin/classes" in pom.xml file.
pom.xml file:
...
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<outputDirectory>bin/classes</outputDirectory>
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With