Reputation: 33881
I'm working with an Android project I've Imported from someone else. I've got all the dependencies sorted, there are no errors in the project, but when I try and launch it, I get:
04-08 16:49:41.761: E/AndroidRuntime(19254): FATAL EXCEPTION: main
04-08 16:49:41.761: E/AndroidRuntime(19254): java.lang.RuntimeException: Unable to
instantiate activity ComponentInfo{com.me.app/com.me.app.ui.ActivityDashboard}:
java.lang.ClassNotFoundException: Didn't find class
"com.me.app.ui.ActivityDashboard"
on path: /data/app/com.me.app-1.apk
My Manifest:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.NoTitleBar">
<activity
android:name=".ui.ActivityDashboard"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
This seems to be a common problem, I've read all the other questions I've found and done the following, all to no avail:
Upvotes: 1
Views: 3952
Reputation: 1006584
and the Library is in the Java Build Path
That is incorrect. Please back out this change, then move the JAR into your project's libs/
directory.
While adding a JAR manually to your build path will satisfy the compiler at compile time, it will not add the contents of the JAR to the APK file at runtime, resulting in ClassNotFoundException
s and the like.
Note that I am referring to third-party JARs, such as the first four entries in your screenshot. None of those appear to be in libs/
, and all need to be.
The sole exceptions for the all-JARs-must-be-in-libs/
rule are:
Android's own platform JAR, attached to your project via selecting the build target (reason: this JAR's contents specifically does not need to be included in your APK)
Android library projects, which have their own libs/
directories for any third-party JARs that they reference
Your core error is that com.me.app.ui.ActivityDashboard
is not found, suggesting that this is from one of your four JARs that are not in libs/
.
Upvotes: 4