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.
You can see Android::Build in action in GitHub Actions at the end of: https://github.com/philiprbrenan/AppaAppsGitHubPhotoApp/blob/main/genApp.pm
sudo apt-get install imagemagick zip openjdk-8-jdk openjdk-8-jre 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.
and unzip to get a copy of sdkmanager which can be used to get the version of the SDK that you want to use, for example:
sdkmanager --list --verbose
Download the SDK components to be used:
(cd android/sdk/; tools/bin/sdkmanager \ echo 'y' | android/sdk/tools/bin/sdkmanager \ 'build-tools;25.0.3' emulator 'platform-tools' \ 'platforms;android-25' 'system-images;android-25;google_apis;x86_64')
Add to these components to the $PATH variable for easy command line use:
export PATH=$PATH:~/android/sdk/tools/:~/android/sdk/tools/bin:\ ~/android/sdk/platform-tools/:~/android/sdk/build-tools/25.0.3
Create an AVD:
avdmanager create avd --name aaa \ -k 'system-images;android-25;google_apis;x86_64' -g google_apis
Start the AVD with a specified screen size (you might need to go into the android/sdk/tools folder):
emulator -avd aaa -skin "2000x1000"
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.
If you wish to include assets with your app, either use buildFolder to specify a build area and place your assets in the assets sub directory of this folder before using compile to compile your app, else use the assets keyword to specify a hash of assets to be included with your app.
A sample app is included in folder:
Modify the values in
to reflect your local environment, then start an emulator and run:
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:
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.
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
Copyright (c) 2016-2019 Philip R Brenan.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.