Android開發中如果將ADT 升級到17以上(包括17),如果你的項目中引用了其它第三方的jar包,在運行是就會報下面的錯誤。這是因為在ADT17以後第三方包統一要放在一個libs的檔案夾中,如果你的第三方包(jar)沒有放在這裡,編譯時間不會將其拷貝到.dex檔案中,因此在運行是會報如下錯誤解決辦法:在你的工程項目下建立一個libs的檔案夾,將jar放到libs檔案夾裡即可。這個問題困擾了好久,開發中一直用的是ADT16,今天終於找到解決辦法了。
08-09 09:58:06.259: W/dalvikvm(1277): Unable to resolve superclass of Lcom/demo/helloworld/widget/viewpagerindicator/simple/BaseSampleActivity; (107)08-09 09:58:06.259: W/dalvikvm(1277): Link of class 'Lcom/demo/helloworld/widget/viewpagerindicator/simple/BaseSampleActivity;' failed08-09 09:58:06.259: W/dalvikvm(1277): Unable to resolve superclass of Lcom/demo/helloworld/widget/viewpagerindicator/simple/SampleCirclesDefault; (451)08-09 09:58:06.259: W/dalvikvm(1277): Link of class 'Lcom/demo/helloworld/widget/viewpagerindicator/simple/SampleCirclesDefault;' failed08-09 09:58:06.259: D/AndroidRuntime(1277): Shutting down VM08-09 09:58:06.259: W/dalvikvm(1277): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)08-09 09:58:06.316: E/AndroidRuntime(1277): FATAL EXCEPTION: main08-09 09:58:06.316: E/AndroidRuntime(1277): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.demo.helloworld/com.demo.helloworld.widget.viewpagerindicator.simple.SampleCirclesDefault}: java.lang.ClassNotFoundException: com.demo.helloworld.widget.viewpagerindicator.simple.SampleCirclesDefault08-09 09:58:06.316: E/AndroidRuntime(1277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)08-09 09:58:06.316: E/AndroidRuntime(1277): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)08-09 09:58:06.316: E/AndroidRuntime(1277): at android.app.ActivityThread.access$600(ActivityThread.java:123)08-09 09:58:06.316: E/AndroidRuntime(1277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)08-09 09:58:06.316: E/AndroidRuntime(1277): at android.os.Handler.dispatchMessage(Handler.java:99)08-09 09:58:06.316: E/AndroidRuntime(1277): at android.os.Looper.loop(Looper.java:137)08-09 09:58:06.316: E/AndroidRuntime(1277): at android.app.ActivityThread.main(ActivityThread.java:4424)08-09 09:58:06.316: E/AndroidRuntime(1277): at java.lang.reflect.Method.invokeNative(Native Method)08-09 09:58:06.316: E/AndroidRuntime(1277): at java.lang.reflect.Method.invoke(Method.java:511)08-09 09:58:06.316: E/AndroidRuntime(1277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)08-09 09:58:06.316: E/AndroidRuntime(1277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)08-09 09:58:06.316: E/AndroidRuntime(1277): at dalvik.system.NativeStart.main(Native Method)08-09 09:58:06.316: E/AndroidRuntime(1277): Caused by: java.lang.ClassNotFoundException: com.demo.helloworld.widget.viewpagerindicator.simple.SampleCirclesDefault08-09 09:58:06.316: E/AndroidRuntime(1277): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)08-09 09:58:06.316: E/AndroidRuntime(1277): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)08-09 09:58:06.316: E/AndroidRuntime(1277): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)08-09 09:58:06.316: E/AndroidRuntime(1277): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)08-09 09:58:06.316: E/AndroidRuntime(1277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)08-09 09:58:06.316: E/AndroidRuntime(1277): ... 11 more