Name
Android::Build - lint, compile, install, run an Android App using the command line tools minus ant and gradle.
Prerequisites
sudo apt-get install imagemagick zip openjdk-8-jdk
sudo cpan install Data::Table::Text Data::Dump Carp POSIX File::Copy;
You will need a version of the Android Build Tools as specified right at the end of this page below all the inappropriate advertising for Android Studio.
Download:
https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
then using the sdkmanager to get the version of the SDK that you want to use, for example:
sdkmanager 'platforms;android-25' 'build-tools;25.0.3
Synopsis
use Android::Build;
my $a = &Android::Build::new(); # Create new builder
$a->buildTools = qq(~/Android/sdk/build-tools/25.0.2/); # Android SDK Build tools folder
$a->icon = qq(~/images/Jets/EEL.jpg); # Image that will be scaled to make an icon using Imagemagick - the English Electric Lightening
$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 key store file
$a->package = qq(com.appaapps.genapp); # Package name containing the activity for this app
$a->platform = qq(~/Android/sdk/platforms/android-25/); # Android SDK platform folder
$a->platformTools = qq(~/Android/sdk/platform-tools/); # Android SDK platform tools folder
$a->src = [q(~/AndroidBuild/SampleApp/src/Activity.java)]; # Source code for the app
$a->title = qq(Generic App); # Title of the app as seen under the icon
$a->run; # Build, install and run the app on the only emulator
Modify the code above to reflect your local environment, then start an emulator and run the modified code to compile your app and load it into the emulator.
Sample App
A sample app is included in folder:
./SampleApp
Modify the values in
./SampleApp/perl/makeWithPerl.pl
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 running emulator.
Signing key
If you do not already have a signing key, you can create one with the supplied script:
./SampleApp/perl/generateAKey.pl
Description
The following sections describe the methods in each functional area of this module. For an alphabetic listing of all methods by name see Index.
Methods and attributes
new()
Create a new default build
This is a static method and so should be invoked as:
Android::Build::new
activity :lvalue
Activity name, default is Activity this the name of the activity to start on the device is package/activity
buildTools :lvalue
Name of the folder containing the build tools to be used to build the app, see prerequisites
buildFolder :lvalue
Name of a folder in which to build the app, The default is ./tmp
classes :lvalue
A folder containing precompiled java classes and jar files that you wish to lint against
debug :lvalue
Make the app debuggable if this option is true
device :lvalue
Device to run on, default is the only emulator
icon :lvalue
Jpg file containing a picture that will be converted and scaled by ImageMagick to make an icon for the app, default is icon.jpg
keyAlias :lvalue
Alias used in the java keytool to name the key to be used to sign this app. See Signing key for how to generate a key.
keyStoreFile :lvalue
Name of key store file. See Signing key for how to generate a key.
keyStorePwd :lvalue
Password of key store file. See Signing key for how to generate a key.
lintFile :lvalue
A file to be linted with the lint action using android.jar and the classes specified.
package :lvalue
The package name to be used in the manifest and to start the app - the file containing the activity for the app should be in this package
parameters :lvalue
Optional parameter string to be placed in folder: res as a string accessible via: R.string.parameters from within the app.
platform :lvalue
Folder containing android.jar - for example Android/sdk/platforms/25.0.2
platformTools :lvalue
Folder containing adb
sdkLevels :lvalue
[minSdkVersion,targetSdkVersion], default is [15,25]
title :lvalue
Title of app, the default is name of app
version :lvalue
Version of app, default is today's date
libs :lvalue
A reference to an array of jar files to be copied into the app build.
log :lvalue
Output: a reference to an array of messages showing all the non fatal errors produced by this running this build. To catch fatal error enclose buildwith 𝗲𝘃𝗮𝗹 {}
permissions :lvalue
A reference to an array of permissions, a standard useful set is applied by default if none are specified.
src :lvalue
A reference to an array of java source files to be compiled to create this app
copySourceFiles()
Copy named source files into position
lint()
Lint the app
install()
Install an already compiled app on the selected device:
compile()
Create the app and then compile it
run()
Create the app, compile it, then install and run it on the selected device
Index
1 activity
4 classes
5 compile
7 debug
8 device
9 icon
10 install
11 keyAlias
12 keyStoreFile
13 keyStorePwd
14 libs
15 lint
16 lintFile
17 log
18 new
19 package
20 parameters
21 permissions
22 platform
24 run
25 sdkLevels
26 src
27 title
28 version
Installation
This module is written in 100% Pure Perl and, thus, it is easy to read, use, modify and install.
Standard Module::Build process for building and installing modules:
perl Build.PL
./Build
./Build test
./Build install
Author
Copyright
Copyright (c) 2016-2017 Philip R Brenan.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.