Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
always build apk with builder class, never with command line
Browse files Browse the repository at this point in the history
  • Loading branch information
mosabua committed Sep 7, 2013
1 parent 74edf0a commit 8cd6ca1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class ApkBuilderWrapper
private ApkBuilder apkBuilder;

/**
* Creates a new APKBuilder. The class must be initialized before calling
* this constructor. This creates a new builder that will create the
* Creates a new APKBuilder. This creates a new builder that will create the
* specified output file, using the two mandatory given input files. An
* optional debug keystore can be provided. If set, it is expected that the
* store password is 'android' and the key alias and password are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,33 +330,12 @@ void createApkFile( File outputFile, boolean signWithDebugKeyStore ) throws Mojo
ArrayList<File> jarFiles = new ArrayList<File>();
ArrayList<File> nativeFolders = new ArrayList<File>();

boolean useInternalAPKBuilder = true;
try
{
initializeAPKBuilder();
// Ok...
// So we can try to use the internal ApkBuilder
}
catch ( Throwable e )
{
// Not supported platform try to old way.
useInternalAPKBuilder = false;
}

// Process the native libraries, looking both in the current build directory as well as
// at the dependencies declared in the pom. Currently, all .so files are automatically included
processNativeLibraries( nativeFolders );

if ( useInternalAPKBuilder )
{
doAPKWithAPKBuilder( outputFile, dexFile, zipArchive, sourceFolders, jarFiles, nativeFolders,
doAPKWithAPKBuilder( outputFile, dexFile, zipArchive, sourceFolders, jarFiles, nativeFolders,
signWithDebugKeyStore );
}
else
{
doAPKWithCommand( outputFile, dexFile, zipArchive, sourceFolders, jarFiles, nativeFolders,
signWithDebugKeyStore );
}

if ( this.apkMetaIncludes != null && this.apkMetaIncludes.length > 0 )
{
Expand Down Expand Up @@ -720,77 +699,6 @@ private static void copyStreamWithoutClosing( InputStream in, OutputStream out )
}
}


/**
* Creates the APK file using the command line.
*
* @param outputFile the output file
* @param dexFile the dex file
* @param zipArchive the classes folder
* @param sourceFolders the resources
* @param jarFiles the embedded java files
* @param nativeFolders the native folders
* @param signWithDebugKeyStore enables the signature of the APK using the debug key
* @throws MojoExecutionException if the APK cannot be created.
*/
private void doAPKWithCommand( File outputFile, File dexFile, File zipArchive, ArrayList<File> sourceFolders,
ArrayList<File> jarFiles, ArrayList<File> nativeFolders,
boolean signWithDebugKeyStore ) throws MojoExecutionException
{
getLog().debug( "Building APK from command line" );
CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
executor.setLogger( this.getLog() );

List<String> commands = new ArrayList<String>();
commands.add( outputFile.getAbsolutePath() );

if ( ! signWithDebugKeyStore )
{
commands.add( "-u" );
}

commands.add( "-z" );
commands.add( new File( project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".ap_" )
.getAbsolutePath() );
commands.add( "-f" );
commands.add( new File( project.getBuild().getDirectory(), "classes.dex" ).getAbsolutePath() );
commands.add( "-rf" );
commands.add( new File( project.getBuild().getOutputDirectory() ).getAbsolutePath() );

if ( nativeFolders != null && ! nativeFolders.isEmpty() )
{
for ( File lib : nativeFolders )
{
commands.add( "-nf" );
commands.add( lib.getAbsolutePath() );
}
}

for ( Artifact artifact : getRelevantCompileArtifacts() )
{
commands.add( "-rj" );
commands.add( artifact.getFile().getAbsolutePath() );
}


getLog().info( getAndroidSdk().getApkBuilderPath() + " " + commands.toString() );
try
{
executor.executeCommand( getAndroidSdk().getApkBuilderPath(), commands, project.getBasedir(),
false );
}
catch ( ExecutionException e )
{
throw new MojoExecutionException( "", e );
}
}


private void initializeAPKBuilder() throws MojoExecutionException
{
// ApkBuilderWrapper.initialize( getLog() );
}

private void processNativeLibraries( final List<File> natives ) throws MojoExecutionException
{
for ( String ndkArchitecture : AndroidNdk.NDK_ARCHITECTURES )
Expand Down

0 comments on commit 8cd6ca1

Please sign in to comment.