集中修复升级ADT22以后ClassNotFoundException的项目
来源:互联网 发布:网络用语 刚 编辑:程序博客网 时间:2024/05/17 04:08
Google前段时间放出了ADT22的版本,很多Android开发人员都升级了,结果一些问题导致和原来的project出现问题,具体表现为:
如果在libs下面引用了其他项目的jar包,会抛ClassNotFoundException,检查后发现bin目录里面的dexedLibs压根没东西,根本没有将libs下面的jar包编译进去。
解决:找到对应project里面的 .classpath文件将
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
改成
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
即可。
可惜我workspace里面的project太多,手工改起来不方便,写个程序吧,处理一下workspace里面的project
import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.io.PrintWriter;import java.util.ArrayList;import java.util.Scanner;public class ProjectFixer {public static void main(String[] args) {System.out.println("Fix workspace after ADT22 upgraded V0.1*");System.out.println("**Please input workspace directory path**");Scanner scanner = new Scanner(System.in);File workspace = new File(scanner.nextLine());if (!workspace.isDirectory()) {System.out.println("**Not a path ! Exiting......**\n");return;}System.out.println("Scanning workspace......");ArrayList<File> progjectFils = scanDir(workspace);System.out.println("Found " + progjectFils.size()+ " Files ,Enter to fix...");scanner.nextLine();scanner.close();fixProject(progjectFils);}static void fixProject(ArrayList<File> progjectFils) { for (File file : progjectFils) {fixClassPathFile(file);}}public static void fixClassPathFile(File inFile) {try {FileInputStream fs = new FileInputStream(inFile);if (!inFile.isFile()) {System.out.println(inFile.getPath()+" is not an existing file");return;}else{System.out.println(inFile.getPath()+" *fixing....");}File tempFile = new File(inFile.getAbsolutePath() + ".tmp");BufferedReader br = new BufferedReader(new InputStreamReader(fs,"UTF-8"));PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(tempFile), "UTF-8"));String line = null;while ((line = br.readLine()) != null) {if (!line.trim().contains("path=\"com.android.ide.eclipse.adt.LIBRARIES\"")) {pw.println(line);pw.flush();} else {pw.println(" <classpathentry exported=\"true\" kind=\"con\" path=\"com.android.ide.eclipse.adt.LIBRARIES\"/>");pw.flush();}}pw.close();br.close();if (!inFile.delete()) {System.out.println("Could not delete file");return;}if (!tempFile.renameTo(inFile))System.out.println("Could not rename file");} catch (FileNotFoundException ex) {ex.printStackTrace();} catch (IOException ex) {ex.printStackTrace();}}static ArrayList<File> scanDir(File dir) {ArrayList<File> classpaths = new ArrayList<File>();for (File projectDir : dir.listFiles()) {if (projectDir.isDirectory()) {for (File frojectFile : projectDir.listFiles()) {if (frojectFile.getName().equals(".classpath"))classpaths.add(frojectFile);}}}return classpaths;}}
- 集中修复升级ADT22以后ClassNotFoundException的项目
- ADT22升级以后出现的bug解决方法
- Android升级ADT22后会报ClassNotFoundException的原因分析
- Android升级ADT22后会报ClassNotFoundException的原因分析
- Android升级ADT22后会报 ClassNotFoundException的原因分析
- Android升级ADT22后会报ClassNotFoundException的原因分析
- Android升级ADT22后会报ClassNotFoundException的原因分析
- Android升级ADT22后会报ClassNotFoundException的原因分析
- Android升级ADT22后会报ClassNotFoundException的原因分析
- 关于升级ADT22后出现java.lang.ClassNotFoundException错误的解决
- 关于升级ADT22后出现java.lang.ClassNotFoundException错误的解决
- 关于升级ADT22后出现java.lang.ClassNotFoundException错误的解决
- 移动开发:Android升级ADT22后会报ClassNotFoundException的原因分析
- Xcode升级以后插件失效的修复
- 关于升级ADT22后无法使用jar包、bundle库,出现java.lang.ClassNotFoundException错误的解决
- 解决更新ADT22后java.lang.ClassNotFoundException的问题。
- 解决Eclipse升级ADT22以后以及Android Studio由于依赖库问题无法直接运行
- SDK 与ADT版本匹配,ADT22.6.0 的升级......
- 双向链表
- ADS问题收集:warning:C2207W:inventing (转载)
- (挑战编程_2_3)Hartals
- c/c++的发展与不同
- 绿色系统收藏分享:萝卜家园系统下载
- 集中修复升级ADT22以后ClassNotFoundException的项目
- 在系统中检测指定的窗口是否已经打开,检查某进程是否存在
- (挑战编程_2_5)Stack 'em Up
- vsftpd安装的问题
- 二十世纪最伟大的10大算法___CS专业用
- VC6.0下设置Unicode编译环境
- dpi 、 dip 、分辨率、屏幕尺寸、px、density 关系以及换算(终结版)
- 强制换行和禁止换行样式
- android退出时关闭整个应用程序