From 7cab46049832302f1b44a0ffdae3ab5f1eb8534c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 3 Jun 2017 09:49:52 -0700 Subject: Update android viewer build instructions. The ant is dead, long live the gradle wrapper! --- docs/android-build-viewer.html | 78 ++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 29 deletions(-) (limited to 'docs') diff --git a/docs/android-build-viewer.html b/docs/android-build-viewer.html index dea1c4fa..af7387a1 100644 --- a/docs/android-build-viewer.html +++ b/docs/android-build-viewer.html @@ -41,10 +41,9 @@ If everything is working, you should be able to run these commands from the command line:
- Android SDK tools: android, emulator, and adb.
+ Android SDK tools: android, emulator, adb and apksigner.
Android NDK tools: ndk-build.
- Oracle Java JDK 8: java, and javac.
- Apache Ant: ant.
+ Oracle Java JDK 8: java, javac and keytool.
Git: git.
GNU Make: make, or gmake.
C compiler: cc, gcc, or clang. @@ -59,16 +58,23 @@ Download the project using Git (and don't forget the --recursive flag): $ git clone --recursive git://git.ghostscript.com/mupdf-android-viewer-mini.git -If all tools have been installed as per the prerequisites, build the app -using make: +

+If all tools have been installed as per the prerequisites, first use your +host compiler to run the 'generate' step in the mupdf project: + +

+$ make -C libmupdf generate
+
+ +

The build the app using the gradle wrapper:

-$ make
+$ ./gradlew assembleDebug
 
-The makefile will take care of setting up the android project and -configuration files. This is of course assuming that you have set -up the pre-requisites properly. +

+You may need to set ANDROID_HOME or add a local.properties configuration +file to point to where you have installed the Android SDK.

Running

@@ -96,14 +102,7 @@ $ adb push file.pdf /mnt/sdcard/Download Then install the app on the device:
-$ make install
-
- -

-In order to build, install, and launch the app in one step: - -

-$ make run
+$ ./gradlew installDebug
 

@@ -119,37 +118,58 @@ $ adb logcat To release you MUST first change the package name. Do NOT use the com.artifex domain for your custom app! -

-$ mv src/com/artifex src/com/YourCompanyName
-
-

Change all references to com.artifex.mupdf.mini into com.YourCompanyName.mupdf.mini in the Java source files and XML resources. +

+$ git mv src/com/artifex src/com/YourCompanyName
+$ sed -i -e s,artifex,YourCompanyName,g AndroidManifest.xml
+$ sed -i -e "s,package com.artifex,package com.YourCompanyName,g" src/com/YourCompanyName/mupdf/mini/*.java
+$ sed -i -e s,artifex,YourCompanyName,g res/layout/*.xml
+
+

In order to sign a release build, you will need to create a key and a key store.

-$ keytool -genkey -v -keystore android.keystore -alias MyKey \
-    -validity 3650 -keysize 2048 -keyalg RSA
+$ keytool -genkey -v -keystore android.keystore -alias MyKey -validity 3650 -keysize 2048 -keyalg RSA
 

-Then add the following entries to local.properties: +Then add the following entries to gradle.properties:

-key.store=android.keystore
-key.store.password=your keystore password
-key.alias=MyKey
-key.alias.password=your key password
+RELEASE_KEY_STORE=android.keystore
+RELEASE_KEY_STORE_PASSWORD=your keystore password
+RELEASE_KEY_ALIAS=MyKey
+RELEASE_KEY_ALIAS_PASSWORD=your key password
 

If your keystore has been set up properly, you can now build a release APK.

-$ make release
+$ ./gradlew assembleRelease
+
+ +

+First verify that the release APK has indeed been signed by the correct key. + +

+apksigner verify --print-certs ./build/outputs/apk/mupdf-x86-debug.apk
+apksigner verify --print-certs ./build/outputs/apk/mupdf-x86-release.apk
+
+ +

+The debug APK should be signed by Android Debug while the release APK +ought to be signed with the key you created above. + +

+Finally install the release app on the device: + +

+$ ./gradlew installRelease
 

-- cgit v1.2.3