Android::Build - Lint, compile, install, run an Android app using the command line tools minus Ant and Gradle thus freeing development effort from the strictures imposed by Android Studio.
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 the page below all the inappropriate advertising for Android Studio.
Download:
wget 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 --list --verbose sdkmanager 'platforms;android-25' 'build-tools;25.0.3' emulator \ 'system-images;android-25;google_apis;x86_64'
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.
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.
If you do not already have a signing key, you can create one with the supplied script:
./SampleApp/perl/generateAKey.pl
Lint, compile, install, run an Android app using the command line tools minus Ant and Gradle thus freeing development effort from the strictures imposed by Android Studio.
The following sections describe the methods in each functional area of this module. For an alphabetic listing of all methods by name see Index.
Create a new build.
This is a static method and so should be invoked as:
Android::Build::new
Activity name: default is Activity. The name of the activity to start on your android device: device is package/Activity
A hash containing your assets folder (if any). Each key is the file name in the assets folder, each corresponding value is the data for that file. The keys of this hash may contain / to create sub folders.
Name of the folder containing the build tools to be used to build the app, see prerequisites
Name of a folder in which to build the app, The default is /tmp/app/
A folder containing precompiled java classes and jar files that you wish to lint against.
The app will be debuggable if this option is true.
Device to run on, default is the only emulator or specify '-d', '-e', or '-s SERIAL' per adb
Create icons in parallel if true - the default is to create them serially which takes more elapsed time.
Jpg file containing a picture that will be converted and scaled by ImageMagick to make an icon for the app, default is icon.jpg in the current directory.
Alias of the key in your key store file which will be used to sign this app. See Signing key for how to generate a key.
Name of your key store file. See Signing key for how to generate a key.
Password of your key store file. See Signing key for how to generate a key.
A reference to an array of jar files to be copied into the app build to be used as libraries.
A file to be linted with the lint action using the android platform and the classes specified.
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 build with eval{}
The package name used in the manifest file to identify the app. The java file containing the activity for this app should use this package name on its package statement.
Optional parameter string to be placed in folder: res as a string accessible via: R.string.parameters from within the app. Alternatively, if this is a reference to a hash, strings are created for each hash key=value
A reference to an array of permissions, a standard useful set is applied by default if none are specified.
Folder containing android.jar. For example ~/Android/sdk/platforms/25.0.2
Folder containing adb
[minSdkVersion, targetSdkVersion], default is [15, 25]
A reference to an array of java source files to be compiled to create this app.
Title of app, the default is the package name of the app.
A hash of translated titles: {ISO::639 2 digit language code=>title in that language}* for this app.
Verify the signed apk if this is true.
The version number of the app. Default is today's date, formatted as YYYYMMDD
Compile the app.
Parameter Description 1 $android Android build
Clone an apk file: copy the existing apk, replace the assets, re-sign, zipalign, return the name of the newly created apk file.
Parameter Description 1 $android Android build 2 $oldApk The file name of the apk to be cloned
Lint all the Java source code files for the app.
Install an already compiled app on to the selected device
Compile the app, install and then run it on the selected device
1 activity
2 assets
3 buildFolder
4 buildTools
5 classes
6 cloneApk
7 compile
8 debug
9 device
10 fastIcons
11 icon
12 install
13 keyAlias
14 keyStoreFile
15 keyStorePwd
16 libs
17 lint
18 lintFile
19 log
20 new
21 package
22 parameters
23 permissions
24 platform
25 platformTools
26 run
27 sdkLevels
28 src
29 title
30 titles
31 verifyApk
32 version
This module is written in 100% Pure Perl and, thus, it is easy to read, comprehend, use, modify and install via cpan:
sudo cpan install Android::Build
philiprbrenan@gmail.com
http://www.appaapps.com
Copyright (c) 2016-2018 Philip R Brenan.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
To install Android::Build, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Android::Build
CPAN shell
perl -MCPAN -e shell install Android::Build
For more information on module installation, please visit the detailed CPAN module installation guide.