今天将ADT升级后(adnroid SDK Tools从20升级到22, Android SDK Build-tools升级到17),突然所有程序不能启动了,报找不到R类,然后layout并没有错误,bin文件夹下也没有生成R.java类,后发现是Android SDK Tools等没有安装。
在Android SDK Manager中安装完Tools文件夹下tools后依然不能启动,异常如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
E/AndroidRuntime(12439): FATAL EXCEPTION: main E/AndroidRuntime(12439): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cn.trinea.android.demo/cn.trinea.android.demo.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "cn.trinea.android.demo.MainActivity" on path: DexPathList[dexElements=[zip file "/data/app/cn.trinea.android.demo-1.apk"],nativeLibraryDirectories=[/data/app-lib/cn.trinea.android.demo-1, /vendor/lib, /system/lib]] E/AndroidRuntime(12439): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2382) E/AndroidRuntime(12439): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2520) E/AndroidRuntime(12439): at android.app.ActivityThread.access$600(ActivityThread.java:168) E/AndroidRuntime(12439): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360) E/AndroidRuntime(12439): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(12439): at android.os.Looper.loop(Looper.java:153) E/AndroidRuntime(12439): at android.app.ActivityThread.main(ActivityThread.java:5508) E/AndroidRuntime(12439): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(12439): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime(12439): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:835) E/AndroidRuntime(12439): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) E/AndroidRuntime(12439): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime(12439): Caused by: java.lang.ClassNotFoundException: Didn't find class "cn.trinea.android.demo.MainActivity" on path: DexPathList[dexElements=[zip file "/data/app/cn.trinea.android.demo-1.apk"],nativeLibraryDirectories=[/data/app-lib/cn.trinea.android.demo-1, /vendor/lib, /system/lib]] E/AndroidRuntime(12439): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) E/AndroidRuntime(12439): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) E/AndroidRuntime(12439): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) E/AndroidRuntime(12439): at android.app.Instrumentation.newActivity(Instrumentation.java:1054) E/AndroidRuntime(12439): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2373) E/AndroidRuntime(12439): ... 11 more |
解决方法:
菜单Project -> Properties -> Java Build Path -> Order & Export, 然后选中Android Private Libraries, 菜单 Project->Clean,然后运行程序即可。
如果依然失败,将相关的依赖工程选中Android Private Libraries并clean然后重试即可
PS:
新版的ADT加快了插件启动速度,增加了Dump View Hierarchy for UI Automator使得界面查看更方便,Capature System Wide Trace貌似是用来性能调优的,不过不支持windows,后面详细了解看看