public final class ApkBuilder extends java.lang.Object implements IArchiveBuilder
| Modifier and Type | Class and Description |
|---|---|
static class |
ApkBuilder.FileEntry |
static interface |
ApkBuilder.JarStatus
Status for the addition of a jar file resources into the APK.
|
static class |
ApkBuilder.SigningInfo
Signing information.
|
| Constructor and Description |
|---|
ApkBuilder(java.io.File apkFile,
java.io.File resFile,
java.io.File dexFile,
java.security.PrivateKey key,
java.security.cert.X509Certificate certificate,
java.io.PrintStream verboseStream)
Creates a new instance.
|
ApkBuilder(java.io.File apkFile,
java.io.File resFile,
java.io.File dexFile,
java.lang.String debugStoreOsPath,
java.io.PrintStream verboseStream)
Creates a new instance.
|
ApkBuilder(java.lang.String apkOsPath,
java.lang.String resOsPath,
java.lang.String dexOsPath,
java.security.PrivateKey key,
java.security.cert.X509Certificate certificate,
java.io.PrintStream verboseStream)
Creates a new instance.
|
ApkBuilder(java.lang.String apkOsPath,
java.lang.String resOsPath,
java.lang.String dexOsPath,
java.lang.String storeOsPath,
java.io.PrintStream verboseStream)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFile(java.io.File file,
java.lang.String archivePath)
Adds a file to the APK at a given path
|
void |
addNativeLibraries(java.io.File nativeFolder)
Adds the native libraries from the top native folder.
|
void |
addNativeLibraries(java.util.List<ApkBuilder.FileEntry> entries) |
ApkBuilder.JarStatus |
addResourcesFromJar(java.io.File jarFile)
Adds the resources from a jar file.
|
void |
addSourceFolder(java.io.File sourceFolder)
Adds the resources from a source folder.
|
static void |
addSourceFolder(IArchiveBuilder builder,
java.io.File sourceFolder)
Adds the resources from a source folder to a given
IArchiveBuilder |
void |
addZipFile(java.io.File zipFile)
Adds the content from a zip file.
|
static boolean |
checkFileForPackaging(java.lang.String fileName)
Checks a file to make sure it should be packaged as standard resources.
|
static boolean |
checkFileForPackaging(java.lang.String fileName,
java.lang.String extension)
Checks a file to make sure it should be packaged as standard resources.
|
static boolean |
checkFolderForPackaging(java.lang.String folderName)
Checks whether a folder and its content is valid for packaging into the .apk as
standard Java resource.
|
static ApkBuilder.SigningInfo |
getDebugKey(java.lang.String storeOsPath,
java.io.PrintStream verboseStream)
Returns the key and certificate from a given debug store.
|
static java.lang.String |
getDebugKeystore() |
static java.util.List<ApkBuilder.FileEntry> |
getNativeFiles(java.io.File nativeFolder,
boolean debugMode) |
void |
sealApk()
Seals the APK, and signs it if necessary.
|
void |
setDebugMode(boolean debugMode)
Sets the debug mode.
|
public ApkBuilder(java.lang.String apkOsPath,
java.lang.String resOsPath,
java.lang.String dexOsPath,
java.lang.String storeOsPath,
java.io.PrintStream verboseStream)
throws ApkCreationException
PrintStream can also be provided for verbose output. If null, there will
be no output.apkOsPath - the OS path of the file to create.resOsPath - the OS path of the packaged resource file.dexOsPath - the OS path of the dex file. This can be null for apk with no code.verboseStream - the stream to which verbose output should go. If null, verbose mode
is not enabled.ApkCreationExceptionpublic ApkBuilder(java.lang.String apkOsPath,
java.lang.String resOsPath,
java.lang.String dexOsPath,
java.security.PrivateKey key,
java.security.cert.X509Certificate certificate,
java.io.PrintStream verboseStream)
throws ApkCreationException
PrivateKey and X509Certificate can be provided to sign the APK.
An optional PrintStream can also be provided for verbose output. If null, there will
be no output.apkOsPath - the OS path of the file to create.resOsPath - the OS path of the packaged resource file.dexOsPath - the OS path of the dex file. This can be null for apk with no code.key - the private key used to sign the package. Can be null.certificate - the certificate used to sign the package. Can be null.verboseStream - the stream to which verbose output should go. If null, verbose mode
is not enabled.ApkCreationExceptionpublic ApkBuilder(java.io.File apkFile,
java.io.File resFile,
java.io.File dexFile,
java.lang.String debugStoreOsPath,
java.io.PrintStream verboseStream)
throws ApkCreationException
PrintStream can also be provided for verbose output. If null, there will
be no output.apkFile - the file to createresFile - the file representing the packaged resource file.dexFile - the file representing the dex file. This can be null for apk with no code.debugStoreOsPath - the OS path to the debug keystore, if needed or null.verboseStream - the stream to which verbose output should go. If null, verbose mode
is not enabled.ApkCreationExceptionpublic ApkBuilder(java.io.File apkFile,
java.io.File resFile,
java.io.File dexFile,
java.security.PrivateKey key,
java.security.cert.X509Certificate certificate,
java.io.PrintStream verboseStream)
throws ApkCreationException
PrivateKey and X509Certificate can be provided to sign the APK.
An optional PrintStream can also be provided for verbose output. If null, there will
be no output.apkFile - the file to createresFile - the file representing the packaged resource file.dexFile - the file representing the dex file. This can be null for apk with no code.key - the private key used to sign the package. Can be null.certificate - the certificate used to sign the package. Can be null.verboseStream - the stream to which verbose output should go. If null, verbose mode
is not enabled.ApkCreationExceptionpublic static ApkBuilder.SigningInfo getDebugKey(java.lang.String storeOsPath, java.io.PrintStream verboseStream) throws ApkCreationException
storeOsPath - the OS path to the debug store.verboseStream - an option PrintStream to display verbose informationApkBuilder.SigningInfo object or null.ApkCreationExceptionpublic void setDebugMode(boolean debugMode)
debugMode - the debug mode flag.public void addFile(java.io.File file,
java.lang.String archivePath)
throws ApkCreationException,
SealedApkException,
DuplicateFileException
addFile in interface IArchiveBuilderfile - the file to addarchivePath - the path of the file inside the APK archive.ApkCreationException - if an error occurredSealedApkException - if the APK is already sealed.DuplicateFileException - if a file conflicts with another already added to the APK
at the same location inside the APK archive.public void addZipFile(java.io.File zipFile)
throws ApkCreationException,
SealedApkException,
DuplicateFileException
zipFile - the zip File.ApkCreationException - if an error occurredSealedApkException - if the APK is already sealed.DuplicateFileException - if a file conflicts with another already added to the APK
at the same location inside the APK archive.public ApkBuilder.JarStatus addResourcesFromJar(java.io.File jarFile) throws ApkCreationException, SealedApkException, DuplicateFileException
jarFile - the jar File.ApkBuilder.JarStatus object indicating if native libraries where found in
the jar file.ApkCreationException - if an error occurredSealedApkException - if the APK is already sealed.DuplicateFileException - if a file conflicts with another already added to the APK
at the same location inside the APK archive.public void addSourceFolder(java.io.File sourceFolder)
throws ApkCreationException,
SealedApkException,
DuplicateFileException
sourceFolder - the source folder.ApkCreationException - if an error occurredSealedApkException - if the APK is already sealed.DuplicateFileException - if a file conflicts with another already added to the APK
at the same location inside the APK archive.public static void addSourceFolder(IArchiveBuilder builder, java.io.File sourceFolder) throws ApkCreationException, DuplicateFileException
IArchiveBuildersourceFolder - the source folder.ApkCreationException - if an error occurredDuplicateFileException - if a file conflicts with another already added to the APK
at the same location inside the APK archive.public void addNativeLibraries(java.io.File nativeFolder)
throws ApkCreationException,
SealedApkException,
DuplicateFileException
nativeFolder - the native folder.ApkCreationException - if an error occurredSealedApkException - if the APK is already sealed.DuplicateFileException - if a file conflicts with another already added to the APK
at the same location inside the APK archive.setDebugMode(boolean)public void addNativeLibraries(java.util.List<ApkBuilder.FileEntry> entries) throws SealedApkException, DuplicateFileException, ApkCreationException
public static java.util.List<ApkBuilder.FileEntry> getNativeFiles(java.io.File nativeFolder, boolean debugMode) throws ApkCreationException
ApkCreationExceptionpublic void sealApk()
throws ApkCreationException,
SealedApkException
ApkCreationExceptionApkCreationException - if an error occurredSealedApkException - if the APK is already sealed.public static java.lang.String getDebugKeystore()
throws ApkCreationException
ApkCreationExceptionpublic static boolean checkFolderForPackaging(java.lang.String folderName)
folderName - the name of the folder.public static boolean checkFileForPackaging(java.lang.String fileName)
fileName - the name of the file (including extension)public static boolean checkFileForPackaging(java.lang.String fileName,
java.lang.String extension)
fileName - the name of the file (including extension)extension - the extension of the file (excluding '.')