final String debugKeyStore = signWithDebugKeyStore ? ApkBuilder.getDebugKeystore() : null; final ApkBuilder apkBuilder = new ApkBuilder( outputFile, zipArchive, dexFile, debugKeyStore, null ); if ( apkDebug ) apkBuilder.setDebugMode( true ); apkBuilder.addResourcesFromJar( innerJar ); apkBuilder.addResourcesFromJar( jarFile ); apkBuilder.addNativeLibraries( nativeFolder ); apkBuilder.sealApk();
/** * Adds all non-class files from folder, so that we can add META-INF/services resources. */ private void addResourcesFromFolder( ApkBuilder builder, File folder ) throws SealedApkException, DuplicateFileException, ApkCreationException, IOException { final int folderPathLength = folder.getCanonicalPath().length(); final List<File> resourceFiles = new ArrayList<>( ); collectFiles( folder, resourceFiles ); for ( final File resourceFile : resourceFiles ) { final String resourceName = resourceFile .getCanonicalPath() .substring( folderPathLength + 1 ) .replaceAll( "\\\\", "/" ); getLog().info( "Adding resource " + resourceFile + " : " + resourceName ); builder.addFile( resourceFile, resourceName ); } }
ApkBuilder builder = new ApkBuilder(outApk, zipArchives.get(0), dexFile, signed ? ApkBuilder.getDebugKeystore() : null, verbose ? System.out : null); builder.setDebugMode(debug); builder.addZipFile(zipArchives.get(i)); builder.addSourceFolder(sourceFolder); builder.addResourcesFromJar(new File(jarFile, filename)); builder.addResourcesFromJar(jarFile); builder.addNativeLibraries(nativeFolder); builder.sealApk();
ApkBuilder builder = new ApkBuilder(new File(binFolder.getAbsolutePath() + "/" + sketchName + ".apk.unsigned"), //The location of the output APK file (unsigned) new File(binFolder.getAbsolutePath() + "/" + sketchName + ".apk.res"), //The location of the .apk.res file new File(binFolder.getAbsolutePath() + "/classes.dex"), //The location of the DEX class file builder.addZipFile(glslFolder); // Location of GLSL files builder.addSourceFolder(srcFolder); // The location of the source folder builder.addZipFile(new File(buildFolder, "vr-lib.zip")); builder.sealApk(); } catch(Exception e) { System.out.println(editor.getResources().getString(R.string.build_building_apkbuilder_failed));
checkOutputFile(mApkFile = apkFile); checkInputFile(mResFile = resFile); if (dexFile != null) { checkInputFile(mDexFile = dexFile); } else { mDexFile = null; certificate); verbosePrintln("Packaging %s", mApkFile.getName()); addZipFile(mResFile); addFile(mDexFile, SdkConstants.FN_APK_CLASSES_DEX);
/** * Builds the {@code sourceApk} with bytecode merged from {@code classesDex}. The built .apk file has the same * name as {@code sourceApk} and is put in {@code outputDir}.<br/> * <br/> * <b>Precondition:</b> The {@code sourceApk} doesn't contain {@code classes.dex}, so the {@code classesDex} can be * merged into it. */ private static File buildApk(File sourceApk, File classesDex, File outputDir) throws Exception { File outputApk; try { outputApk = new File(outputDir, sourceApk.getName()); ApkBuilder builder = new ApkBuilder(outputApk, sourceApk, classesDex, ApkBuilder.getDebugKeystore(), null); builder.sealApk(); } catch (ApkCreationException e) { throw new Exception(e); } catch (SealedApkException e) { throw new Exception(e); } return outputApk; }
/** * Adds the resources from a source folder. * @param sourceFolder the source folder. * @throws ApkCreationException if an error occurred * @throws SealedApkException if the APK is already sealed. * @throws DuplicateFileException if a file conflicts with another already added to the APK * at the same location inside the APK archive. */ public void addSourceFolder(File sourceFolder) throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } addSourceFolder(this, sourceFolder); }
private void addSecondaryDexes( File dexFile, ApkBuilder apkBuilder ) throws ApkCreationException, SealedApkException, DuplicateFileException { int dexNumber = 2; String dexFileName = getNextDexFileName( dexNumber ); File secondDexFile = createNextDexFile( dexFile, dexFileName ); while ( secondDexFile.exists() ) { apkBuilder.addFile( secondDexFile, dexFileName ); dexNumber++; dexFileName = getNextDexFileName( dexNumber ); secondDexFile = createNextDexFile( dexFile, dexFileName ); } }