1 package com.android.dx.merge; 2 3 import com.android.dex.Dex; 4 import com.android.dex.DexIndexOverflowException; 5 6 import java.io.File; 7 8 /** 9 * This test tries to merge given dex files at random, 2 by 2. 10 */ 11 public class MergeTest { 12 13 private static final int NUMBER_OF_TRIES = 1000; 14 main(String[] args)15 public static void main(String[] args) throws Throwable { 16 17 for (int i = 0; i < NUMBER_OF_TRIES; i++) { 18 String fileName1 = args[(int) (Math.random() * args.length)]; 19 String fileName2 = args[(int) (Math.random() * args.length)]; 20 try { 21 Dex toMerge = new Dex(new File(fileName1)); 22 Dex toMerge2 = new Dex(new File(fileName2)); 23 new DexMerger(toMerge, toMerge2, CollisionPolicy.KEEP_FIRST).merge(); 24 } catch (DexIndexOverflowException e) { 25 // ignore index overflow 26 } catch (Throwable t) { 27 System.err.println( 28 "Problem merging those 2 dexes: \"" + fileName1 + "\" and \"" + fileName2 + "\""); 29 throw t; 30 } 31 } 32 } 33 } 34