Reputation: 31
Afrer I build the sample code and install it on my Nexus 4. I use Eclipse and import WearableNotificationsSample, ElizaChat sample code of AndroidWearPreview. It failed. why?
03-20 14:34:34.418: E/AndroidRuntime(9989): Process: com.example.android.preview.support.wearable.notifications, PID: 9989
03-20 14:34:34.418: E/AndroidRuntime(9989): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.preview.support.wearable.notifications/com.example.android.preview.support.wearable.notifications.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.android.preview.support.wearable.notifications.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.preview.support.wearable.notifications-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.preview.support.wearable.notifications-2, /vendor/lib, /system/lib]]
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.os.Handler.dispatchMessage(Handler.java:102)
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.os.Looper.loop(Looper.java:136)
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-20 14:34:34.418: E/AndroidRuntime(9989): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 14:34:34.418: E/AndroidRuntime(9989): at java.lang.reflect.Method.invoke(Method.java:515)
03-20 14:34:34.418: E/AndroidRuntime(9989): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-20 14:34:34.418: E/AndroidRuntime(9989): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-20 14:34:34.418: E/AndroidRuntime(9989): at dalvik.system.NativeStart.main(Native Method)
03-20 14:34:34.418: E/AndroidRuntime(9989): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.preview.support.wearable.notifications.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.preview.support.wearable.notifications-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.preview.support.wearable.notifications-2, /vendor/lib, /system/lib]]
03-20 14:34:34.418: E/AndroidRuntime(9989): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-20 14:34:34.418: E/AndroidRuntime(9989): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-20 14:34:34.418: E/AndroidRuntime(9989): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-20 14:34:34.418: E/AndroidRuntime(9989): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
Upvotes: 3
Views: 2193
Reputation: 118
I had the same problem. I compared my project with the same project loaded in another Eclipse that was working. In the working project, the android-support-v4.jar is included both in the "Referenced libraries" folder, and in the "Android private libraries" folder. In the failing project, the file only appeared under the "Referenced libraries". So it seems, in some Eclipse instances, the "Build Path > Add to Build Path" does not work as expected, but I was not able to make it work :-(
Upvotes: 0
Reputation: 31
Create "libs" folder at root level then copy "android-support-v4.jar" & "wearable-preview-support.jar". Then right click on each jar file then select "Build Path->Add Build Path". Right click on "Java" folder from project & select "Build Path -> Use as Source Folder". And build it. I hope this will resolve.
Upvotes: 0
Reputation: 2701
I noticed the source code is in the java
folder. To run this on eclipse, the fix was to right click on the java
folder and select Build Path -> Use as Source Folder
Also add the support and android wearable-preview libraries of course
Upvotes: 6
Reputation: 457
(Sorry, not enough reputation for posting a comment)
Having the same issue. I'm using Eclipse and did the suggested actions:
In your Android app project, create a libs/ directory in your project root (the same location as the AndroidManifest.xml file). Copy the v4 support library JAR file from your Android SDK directory (e.g., /extras/android/support/v4/android-support-v4.jar) into your project libs/ directory. Also save the wearable-preview-support.jar file in the libs/ directory. Right click each JAR file and select Build Path > Add to Build Path.
Installed Android Studio and imported it, it's working right away...
Upvotes: 1