src/main/java/com/simpligility/maven/plugins/android/AbstractAndroidMojo.java
protected String extractPackageNameFromApk( File apkFile ) throws MojoExecutionException
    {
        CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
        executor.setLogger( this.getLog() );
        executor.setCaptureStdOut( true );
        executor.setCaptureStdErr( true );

        AaptCommandBuilder commandBuilder = AaptCommandBuilder
                .dump( getLog() )
                .xmlTree()
                .setPathToApk( apkFile.getAbsolutePath() )
                .addAssetFile( "AndroidManifest.xml" );

        getLog().info( getAndroidSdk().getAaptPath() + " " + commandBuilder.toString() );
        try
        {
            executor.executeCommand( getAndroidSdk().getAaptPath(), commandBuilder.build(), false );
            final String xmlTree = executor.getStandardOut();
            return extractPackageNameFromAndroidManifestXmlTree( xmlTree );
        }
        catch ( ExecutionException e )
        {
            throw new MojoExecutionException(
                    "Error while trying to figure out package name from inside apk file " + apkFile );
        }
        finally
        {
            String errout = executor.getStandardError();
            if ( ( errout != null ) && ( errout.trim().length() > 0 ) )
            {
                getLog().error( errout );
            }
        }
    }
protected String extractPackageNameFromApk( File apkFile ) throws MojoExecutionException
    {
        CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
        executor.setLogger( this.getLog() );
        executor.setCaptureStdOut( true );
        executor.setCaptureStdErr( true );

        AaptCommandBuilder commandBuilder = AaptCommandBuilder
                .dump( getLog() )
                .xmlTree()
                .setPathToApk( apkFile.getAbsolutePath() )
                .addAssetFile( "AndroidManifest.xml" );

        getLog().info( getAndroidSdk().getAaptPath() + " " + commandBuilder.toString() );
        try
        {
            executor.executeCommand( getAndroidSdk().getAaptPath(), commandBuilder.build(), false );
            final String xmlTree = executor.getStandardOut();
            return extractPackageNameFromAndroidManifestXmlTree( xmlTree );
        }
        catch ( ExecutionException e )
        {
            throw new MojoExecutionException(
                    "Error while trying to figure out package name from inside apk file " + apkFile );
        }
        finally
        {
            String errout = executor.getStandardError();
            if ( ( errout != null ) && ( errout.trim().length() > 0 ) )
            {
                getLog().error( errout );
            }
        }
    }
protected String extractPackageNameFromApk ( File apkFile ) throws MojoExecutionException { CommandExecutor executor = CommandExecutor . Factory . createDefaultCommmandExecutor ( ) ; executor . setLogger ( this . getLog ( ) ) ; executor . setCaptureStdOut ( true ) ; executor . setCaptureStdErr ( true ) ; AaptCommandBuilder commandBuilder = AaptCommandBuilder . dump ( getLog ( ) ) . xmlTree ( ) . setPathToApk ( apkFile . getAbsolutePath ( ) ) . addAssetFile ( "AndroidManifest.xml" ) ; getLog ( ) . info ( getAndroidSdk ( ) . getAaptPath ( ) + " " + commandBuilder . toString ( ) ) ; try { executor . executeCommand ( getAndroidSdk ( ) . getAaptPath ( ) , commandBuilder . build ( ) , false ) ; final String xmlTree = executor . getStandardOut ( ) ; return extractPackageNameFromAndroidManifestXmlTree ( xmlTree ) ; } catch ( ExecutionException e ) { throw new MojoExecutionException ( "Error while trying to figure out package name from inside apk file " + apkFile ) ; } finally { String errout = executor . getStandardError ( ) ; if ( ( errout != null ) && ( errout . trim ( ) . length ( ) > 0 ) ) { getLog ( ) . error ( errout ) ; } } }
Extracts the package name from an apk file.

@param apkFile apk file to extract package name from.
@return the package name from inside the apk file.
Extracts the package name from an apk file .