For someone who doesn’t write code for a living, creating even the simplest Android app can be a daunting proposition. Fortunately for those of us with basic coding skills, there is Jasonette. In simple terms, Jasonette makes it possible to create a full-featured Android app using a single JSON file that describes the appearance and behavior of the accompanying Android app. To build the latter, you only need to modify a few simple settings in a ready-made app template, such as URL to the JSON file and the app’s name and icon, and then compile the app in the Android Studio IDE.
Creating a Jasonette-based app requires some working knowledge of JSON, but if poring over Jasonette documentation and writing JSON code is not your cup of tea, there is an even easier way to build a simple Android app for showcasing your photos using a PHP script that powers the Tōkyō Taxi Lights app. The script automatically finds all photos in the current directory, picks randomly a specified number of photos, and generates a JSON file on the fly. This file is then used to render the picked photos in the accompanying Android app.
The first step is to download and install Android Studio on your machine. To do this on openSUSE, run the following commands:
sudo mv android-studio-xx-xxx-xxx.zip /opt cd /opt sudo unzip android-studio-xx-xxx-xxx.zip sudo chown -R root:root android-studio sudo ln -s /opt/android-studio/bin/studio.sh /usr/local/bin/android-studio
To host the PHP script and photos, you need a web server with PHP. To keep things tidy, create a dedicated directory (e.g., app) in the document root of the server for storing photos and the script. Before you add photos to this directory, it’s a good idea to reduce their size. This will make your app run faster and reduce the amount of data that needs to be transferred. You can use the jpeg-recompress and mogrify tools to do this. With these two tools installed on your system, you can use the following command to recompress or resize all .jpg files in the current directory:
for file in *.jpg; do jpeg-recompress --quality high $file $file; done mogrify -resize "1600>" *.jpg
Upload then the processed photos to the app directory on your web server.
If you have Git installed on your system, clone the jasonette-tokyo-taxi repository using the
git clone https://gitlab.com/dmpop/jasonette-tokyo-taxi.git command. Alternatively, you can get the source code directly from the project’s website as an archive in the format of your choice. Switch to the resulting jasonette-tokyo-taxi directory, and open the json.php file in a text editor. In the User-defined values section, edit the default values. Save the changes and copy the file to the app directory on your web server.
git clone https://github.com/Jasonette/JASONETTE-Android.git command to clone the JASONETTE-Android app’s source code. Launch Android Studio by running the
android-studio command in the terminal, and import the JASONETTE-Android project. Open the app → res → values → strings.xml file, locate the
Jasonette line and replace Jasonette with the desired name. Replace then the default URL in the
string name="url" https://jasonette.github.io/Jasonpedia/hello.json line with the actual URL to your JSON file. Next, prepare an image file in the PNG format for use as an app icon. In Android Studio, right-click on the app → res folder and choose New → Image Asset. Use a PNG file to create and add an app icon.
Open the Gradle Scripts → build.gradle(Module:app) file, locate the
applicationId "com.jasonette." line, and replace com.jasonette with the desired app ID. Press the Sync Now link to synchronize the changes. Now, choose Build → Build APK(s) to build the app.
To install the resulting app-debug.apk package on an Android device, switch to Settings → Security and enable the Unknown Sources option.