++ed by:

1 non-PAUSE user.

Philip R Brenan

Name

Android::Build - Lint, compile, install, start an Android App using just the command line tools without using ant or gradle, just 100% Pure Perl

Prerequisites

 sudo apt-get install imagemagick zip openjdk-8-jdk
 sudo cpan install Data::Table::Text Data::Dump Carp POSIX File::Copy;

And a version of the Android Software Development Kit.

Synopsis

This file which can be found in the tar.gz file containing this module:

  SampleApp/perl/makeWithperl.pl

contains:

 use Android::Build;

 my $a = &Android::Build::new();

 $a->title        = qq(Generic App);                                            # Title of the app as seen under the icon
 $a->domain       = qq(com.appaapps);                                           # Domain name in reverse order
 $a->activity     = qq(Activity);                                               # Name of Activity = $activity.java file containing onCreate() for this app
 $a->icon         = qq(~/images/Jets/EEL.jpg);                                  # Image that will be scaled to make an icon using Imagemagick
 $a->sdk          = qq(~/Android/sdk/);                                         # Android SDK on the local machine
 $a->sdkLevels    = [15,25];                                                    # Min sdk, target sdk for manifest
 $a->androidJar   = $a->sdk."platforms/android-25/android.jar";                 # Android sdk jar
 $a->keyAlias     = qq(xxx);                                                    # Alias of key to be used to sign this app
 $a->keyStoreFile = qq(~/keystore/release-key.keystore);                        # Key store file
 $a->keyStorePwd  = qq(xxx);                                                    # Password for keystore

 $a->build(qw(run));                                                            # Build, install and run the app on the only emulator

Modify the values above to reflect your local environment, then start an emulator and run:

 perl SampleApp/perl/makeWithPerl.pl

to compile the sample app and load it into the emulator.

If you do not already have a signing key, you can create one with the supplied script:

 perl SampleApp/perl/generateAKey.pl

File layout

If your Android build description is in file:

 /somewhere/$folder/perl/makeWithPerl.pl

then the Java source and libs for your app should be in:

 /somewhere/$folder/src/*.java
 /somewhere/$folder/libs/*.jar

and the java package name for your app should be:

 package $domain.$folder

where:

 $domain

is your reversed domain name written in lowercase. Executing:

 use Android::Build;

 my $a = &Android::Build::new();
 ...
 $a->build(qw(run));

will copy the files in the 𝘀𝗿𝗰 and 𝗹𝗶𝗯 folders into an Android project created in the app build folder before starting the build of your app.

If this does not meet your requirements, then provide a 𝘀𝘂𝗯

 $a->copyFiles = sub ...

which will be called just before the build begins to allow you to copy in any other files needed to build your app.

Parameters

You can customize your build by assigning to or reading from the following methods:

activity

Optional: Activity name, default is 'Activity'

buildTools

REQUIRED: Name of the folder containing the build tools to be used to build the app

buildFolder

Optional: Name of a folder in which to build the app

copyFiles

Optional: Sub to copy additional files into the app before it is complied

debug

Optional: Make app debuggable is specified and true

device

Optional: Device to run on, default is the only emulator

domain

REQUIRED: Domain name for app

icon

Optional: Jpg file containing a picture that will be scaled to make an icon for the app, default is 'icon.jpg'

keyAlias

REQUIRED: alias used in keytool to name the key to be used to sign this app

keyStoreFile

REQUIRED: file name of key store

keyStorePwd

REQUIRED: password of key store file

log

Output: message log

libs

Optional: extra libraries

name

Optional: One word name of app, else the name of the folder: '../'

parameters

Optional: Parameter string to be placed in res for the app

permissions

Optional: Permissions, a standard useful set is applied

sdk

REQUIRED: Folder containing Android sdk

sdkLevels

Optional: [minSdkVersion,targetSdkVersion], default is [15,25]

src

Optional: Source of app, default is everything in './src' folder

target

Optional: Number of android sdk to use as found via `android list targets`

title

Optional: Title of app, default is the name of app

version

Optional: Version of app, default is today's date

Installation

Standard Module::Build process for building and installing modules:

  perl Build.PL
  ./Build
  ./Build test
  ./Build install

Author

philiprbrenan@gmail.com

http://www.appaapps.com

Copyright

Copyright (c) 2017 Philip R Brenan.

This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.