ant 优化android 项目编译第二波,simple编译项目只需1分钟

阅读更多
 
 

 由于第一次的脚本在改动java文件后仍需约五分钟,现进行第二次优化,

上片请进 http://liuqzan.iteye.com/blog/951995

 

 

 

分析:编译耗时主要在资源文件引用的生成和资源文件的打包与二进制处理流程中

对于一个只修改了java文件的项目而言,无需重新执行资源文件的打包与二进制流程

上一个ant 在只修改了java文件的时候编译仍需5mins因为重复生成 二进制 资源文件,此步可以在没有资源文件更改的情况下,只需执行过一次,以后编译时可以省去

 

 

ant 脚本优化生成三个功能:

1generate R:   更新R文件 耗时约4mins

2package-resources   : 在有资源文件改变的情况下打包生成资源文件,耗时约4 mins

3simple 在没有资源文件改变,只改变的JAVA相关文件,且之前执行过一次package-resources ,生成apk只需一分钟。

 

针对以前三种开发情境,现在处理:

在资源文件更改, 不用生成apk,只需要使用资源引用的情况(5%) :使用命令 ant generateR 只更新R文件 耗时 约4mins

更新了资源文件,又修改了JAVA文件想立即生成apk(5%) 则联合使用:ant generateR à  ant package-resources à ant  simple  10mins

频繁修改java类文件,资源文件不变,只需要生成apk(90%):使用命令ant simple  ,耗时约  1mins

 

优点:

可操作性强,三个处理流相互独立,处理时互不影响

节约时间,定制编译

 

缺点:需要手动使用ant 命令 

 


ant 优化android 项目编译第二波,simple编译项目只需1分钟_第1张图片

 

 

 





    

    
    

    
    

    
    
        
        
        
    

    





    
    
	

	    
	    

	    

	    

	    

	    
		
	    
	    

	    
	    

	    
	    
	    
	    
	    
	    
	    

	    
	    
	    
	    
	    
	    
	    
	    
	    

	    
	    
	    

	    
	    
	    

	    
	    
	    
	    
	    
	    

	    
	    
	    
	    

	    
	    
	    

	    
	    

	    
	    

	    
	    

	    
	    
	    
	    

	    
	    
	    
	    
	        
	    
	    
	    
	        
	    
	    
	    
	        
	    

	    
	    
	        
	            
	            
	            
	        
	    
	    
	        
	            
	            
	            
	        
	    

	    
	    
	    
	    

	    
	    
	        
	            
	            
	        
	    
	    

	    

	    
	    
	       
	       
	       
	         Converting compiled files and external libraries into ${intermediate.dex.file}...
	         
	             
	             
	             
	             
	             
	             
	             
	             
	         
	       
	    

	    
	    
	        
	        
	        
	        
	            
	                
	                
	                
	                
	                
	                
	                
	                
	            
	        
	    

	    
	    
	        
	        
	        
	            Running zip align on final apk...
	            
	                
	                
	                
	                
	                
	            
	        
	    

	    
	    
	        
	            Installing ${out.debug.file} onto default emulator or device...
	            
	                
	                
	                
	                
	            
	        
	    

	    
		
	
	    
	        
	    
	    
	    
	        Creating output directories if needed...
	        
	        
	        
	        
	            
	                
	                
	            
	        
	    

	    
	    

	    
	    
	        
	            
	                Generating R.java / Manifest.java from the resources...
	            	
	            	
	            	                    
	            	                
	            	
	            
	            
	                hasCode = false. Skipping...
	            
	        
	    

	    
	    
	        
	            
	                Compiling aidl files into Java classes...
	                
	                    
	                    
	                
	            
	            
	                hasCode = false. Skipping...
	            
	        
	    

	    
	    

	    
	    
	        
	            
	                
	                
	                    
	                
	                
	                    
	                
	                
	                	
	                	
	                	
	                	
	                    
	                    
	                    
	                	
	                    	
	                        
	                        
	                    
	                
	            
	            
	                hasCode = false. Skipping...
	            
	        
	    
		
	
		    
		    	simplecompile start at time
		    	
		            
		                
		                
		                    
		                
		                
		                    
		                
		                
		                	
		                	
		                	
		                	
		                    
		                    
		                    
		                	
		                    	
		                        
		                        
		                    
		                
		            
		            
		                hasCode = false. Skipping...
		            
		        
		    	simplecompile end at time 
		    
		
	    
	    

	    
	    
	        
	            
	                
	            
	            
	                hasCode = false. Skipping...
	            
	        
	    
	
	  
		    
		    	-simpledex start at time 
		        
		            
		                
		            
		            
		                hasCode = false. Skipping...
		            
		        
		    	-simpledex end at time  
		   

	    
	    
	        Packaging resources start at time
	    	Packaging resources start at time  
	        
	            
	            
	            
	        
	    	Packaging resources end at time
	    
	
	    
		        Packaging resources start at time
		    	Packaging resources start at time  
		        
		            
		            
		            
		        
		    	Packaging resources end at time
		 

	    
	    
	        
	    
	
	    
		    
		        
		
		
	
			    
			        
			
		 

	    
	    
	        
	    

	    
	       
	            
	       
	    
	
	    
		       
		            
		       
		 

	    
	    
	        
	        Debug Package: ${out.debug.file}
	    
	
	    
		
			Debug Package: ${out.debug.unaligned.file}   
			
		
	
	
			
				Debug Package: ${out.debug.unaligned.file}   
				
			

	    
	    
	        
	        
	        
	    

	    
	    
	        No key.store and key.alias properties found in build.properties.
	        Please sign ${out.unsigned.file} manually
	        and run zipalign from the Android SDK tools.
	    

	    
	        
	    

	    
	    
	        
	        Signing final apk...
	        

	        
	        
	        Release Package: ${out.release.file}
	    

	    
	        
	    

	    
	        
	           
	        
	    

	    
	        Unable to run 'ant uninstall', manifest.package property is not defined.
	        
	    

	    
	    
	        Uninstalling ${manifest.package} from the default emulator or device...
	        
	            
	            
	            
	        
	    

	    
	        
	        
	    
	   
		        
		
	    

	    
	    
	        Instrumenting classes from ${out.absolute.dir}/classes...
	        
	        
	            
	            
	            
	        
	    

	    
	       
	          
	            
	          
	          
	            
	          
	       
	    

	    
	    
	        
	            
	                
	                
	            
	        
	    

	    
	        
	    

	    
	        
	    

	    

	    
	    	
	    	Modified Android Ant Build. Available targets:
	    	   generateR:     Generates the R.java file for this project's resources.	    
	           simplecompile:   Compiles project's .java files into .class files.
	           simpledebug:     Builds the application and signs it with a debug key.
	    
	        
	        Android Ant Build. Available targets:
	           help:      Displays this help.
	           clean:     Removes output files created by other targets.
	           compile:   Compiles project's .java files into .class files.
	           debug:     Builds the application and signs it with a debug key.
	           release:   Builds the application. The generated apk file must be
	                      signed before it is published.
	           install:   Installs/reinstalls the debug package onto a running
	                      emulator or device.
	                      If the application was previously installed, the
	                      signatures must match.
	           uninstall: Uninstalls the application from a running emulator or
	                      device.
	    
	
	
 
 

 

 

 

 

 

  • ant 优化android 项目编译第二波,simple编译项目只需1分钟_第2张图片
  • 大小: 46 KB
  • 查看图片附件

你可能感兴趣的:(Android,Ant,XML,脚本,OS)