This instruction helps you to create Google play Instant App in Defold.
Instruction
Preparation
- Download android sdk tools for your platform:
macOS: https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip
Windows: https://dl.google.com/android/repository/tools_r25.2.3-windows.zip
Linux: https://dl.google.com/android/repository/tools_r25.2.3-linux.zip - Unpack, and copy
tools
folder intoandroid-sdk
folder. - Install build tools:
android-sdk/tools/bin/sdkmanager --verbose “build-tools;25.0.3”
Commands for all preparation steps:
mkdir ~/android
cd ~/android
mkdir android-sdk
# Supported: macosx,linux,windows
PLATFORM=macosx
TOOL_VERSION=25.2.3
wget https://dl.google.com/android/repository/tools_r$TOOL_VERSION-$PLATFORM.zip
tar xvf tools_r$TOOL_VERSION-$PLATFORM.zip
mv tools android-sdk/tools
./android-sdk/tools/bin/sdkmanager --verbose "build-tools;25.0.3"
Let’s do it!
- Create custom AndroidManifest.xml
- Add next two lines into
<manifest>
tag:
xmlns:dist="http://schemas.android.com/apk/distribution"
android:targetSandboxVersion="2"
How it looks:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="{{android.package}}"
android:versionCode="{{android.version_code}}"
android:versionName="{{project.version}}"
android:installLocation="auto"
xmlns:dist="http://schemas.android.com/apk/distribution"
android:targetSandboxVersion="2">
- Build apk
- Align your apk:
android-sdk/build-tools/25.0.3/zipalign -f -v 4 your_apk_full_path.apk aligned_apk_path.apk
- Re-sign your apk:
android-sdk/build-tools/25.0.3/apksigner sign --key path/to/your/key.pk8 --cert path/to/your/certificate.pem aligned_apk_path.apk
- Create zip archive with
aligned_apk_path.apk
(result of step 5) - Now you can upload this zip as android instant app:
Troubleshooting
Your Instant App APKs must be a ‘.zip’ file.
You forgot about step 7, just archive you apk as zip.
Upload failed
Your Instant App APKs do not declare a valid ‘android:targetSandboxVersion’ attribute in their AndroidManifest. Using the ‘com.android.feature’ Gradle plugin to build your Instant App would add this attribute automatically.
You forgot about step 2, add needed lines into AndroidManifest.xml file.
Upload failed
You uploaded an APK with an invalid signature (learn more about signing). Error from apksigner: ERROR: NO_SIG_FOR_TARGET_SANDBOX_VERSION: Missing APK Signature Scheme v2 signature required for target sandbox version 2
You forgot about step 4 and 5. Apk should be aligned and re-signed.
Example.
- Open game page in Google play https://play.google.com/store/apps/details?id=com.potatojam.classic.solitaire.klondike
- Tap to “Try Now” button