Add MultiDex "YAIL compiler - ApkBuilder failed"?

92 views
Skip to first unread message

Mas K

unread,
Feb 4, 2019, 9:30:14 PM2/4/19
to App Inventor Open Source Development

Add MultiDex "YAIL compiler - ApkBuilder failed"?

im add "ThirdDex" on compiler.java like:

private boolean runApkBuilder(String apkAbsolutePath, String zipArchive, String dexedClassesDir) {
    try {
      ApkBuilder apkBuilder =
          new ApkBuilder(apkAbsolutePath, zipArchive,
            dexedClassesDir + File.separator + "classes.dex", null, System.out);
      if (hasSecondDex) {
        apkBuilder.addFile(new File(dexedClassesDir + File.separator + "classes2.dex"), "classes2.dex");
      }
  if (hasThirdDex) {
        apkBuilder.addFile(new File(dexedClassesDir + File.separator + "classes3.dex"), "classes3.dex");
      }    
  if (nativeLibsNeeded.size() != 0) { // Need to add native libraries...
       apkBuilder.addNativeLibraries(libsDir);
      }
      apkBuilder.sealApk();
      return true;
    } catch (Exception e) {
      // This is fatal.
      e.printStackTrace();
      LOG.warning("YAIL compiler - ApkBuilder failed.");
      err.println("YAIL compiler - ApkBuilder failed.");
      userErrors.print(String.format(ERROR_IN_STAGE, "ApkBuilder"));
      return false;
    }
  }


and im always get error "YAIL compiler - ApkBuilder failed." for firts build and  "BUILD SUCCESSFUL" for second time.
with off fuction:
 //if (nativeLibsNeeded.size() != 0) { // Need to add native libraries...
      // apkBuilder.addNativeLibraries(libsDir);
    //  }

any solution sir?
whats code to fix?

Thanks.

Evan Patton

unread,
Feb 6, 2019, 9:49:01 AM2/6/19
to App Inventor Open Source Development
I would recommend not commenting out the lines in question as that adds the native libraries required for the WebRTC connection to work. The way the multidex building works is a bit naive. Basically, when dx fails we attempt to split the set of libraries in half and compile them into two separate dex files (see runDx(File,String,boolean)). You will also need to adjust the logic in that method to handle the creation of the third dex if you haven't already, and you should expect to see multiple failures (2 in this case if you can't build a whole dex nor two dexes) prior to a success. You'll note that this happens with appinventor-sources master as well (only 1 failure though, because we only create 2 dexes).

Regards,
Evan

Mas K

unread,
Feb 7, 2019, 2:57:23 PM2/7/19
to App Inventor Open Source Development
Thanks sir @Evan for you respone :D

I have done add logic or method to handle the creation thirddex .
and now is FIX.

Thanks

MRKY 4M

unread,
Jul 20, 2019, 10:07:39 AM7/20/19
to App Inventor Open Source Development
I am facing this issue while adding third Class

 Using Pre-Dexed dex-cached-022f59587e1a41e43d2a31c26bce12ad.jar <- C:\Windows\TEMP\google-play-services6290329896137655736.jar                                                      
     [java] Converting compiled files and external libraries into C:\Windows\TEMP\1563631586117_0.990015075198901-0\youngandroidproject\..\build\tmp\classes3.dex...                            
     [java]                                                                                                                                                                                     
     [java] UNEXPECTED TOP-LEVEL EXCEPTION:                                                                                                                                                     
     [java] com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536                                                                                                      
     [java]     at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:512)                                                                                                             
     [java]     at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:272)                                                                                                      
     [java]     at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:521)                                                                                                            
     [java]     at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)                                                                                                                
     [java]     at com.android.dx.merge.DexMerger.merge(DexMerger.java:194)                                                                                                                     
     [java]     at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:506)                                                                                                      
     [java]     at com.android.dx.command.dexer.Main.runMonoDex(Main.java:336)                                                                                                                  
     [java]     at com.android.dx.command.dexer.Main.runDx(Main.java:291)                                                                                                                       
     [java]     at com.android.dx.command.dexer.Main.main(Main.java:247)                                                                                                                        
     [java]     at com.android.dx.command.Main.main(Main.java:94)                                                                                                                               
     [java]                                                                                                                                                                                     
     [java] Picked up _JAVA_OPTIONS:  -Xmx1024m                                                                                                                                                 
     [java] Jul 20, 2019 7:06:46 AM com.google.appinventor.buildserver.Compiler runDx                                                                                                           
     [java] INFO: DX execution failed, trying with fewer libraries.                                                                                                                             
     [java] Jul 20, 2019 7:06:46 AM com.google.appinventor.buildserver.Compiler runDx                                                                                                           
     [java] WARNING: YAIL compiler - DX execution failed (secondTry!).                                                                                                                          
     [java] Picked up _JAVA_OPTIONS:  -Xmx1024m                                                                                                                                                 
     [java] Java Result: 1                                                                                                                                                                      
                                                                                                                                                                                                
BUILD SUCCESSFUL                                                                                                                                                                                
Total time: 40 seconds                                                                                                                                                                          
Picked up _JAVA_OPTIONS:  -Xmx1024m                                                                                                                                                             

Ruben Baena Perez

unread,
Sep 11, 2019, 7:09:09 AM9/11/19
to App Inventor Open Source Development
Would you please share the necessary code for the class3.dex?
Reply all
Reply to author
Forward
0 new messages