The author

Hello, I’m Ippo.

I graduated from Hunan Agricultural University in 2018 and joined the 37 Mobile Game Android team in June 2021.

Currently responsible for overseas game release and Android development.

background

The last article covered how to convert from APK to AAB, which works for most applications, but for high quality games and large apps, Google’s mandatory “no upload” for packages over 150MB is another challenge. You need to use Google to provide Play Asset Delivery to expand the package size.

What is Play Asset Delivery (PAD)?

Play Asset Delivery (PAD) brings the benefits of App Bundle to games. It allows games over 150 MB to replace older extension files (OBBs) by publishing a single artifact to Play that contains all the resources needed for the game. The PAD offers a flexible distribution model, automatic update, compression, and incremental patching, and is free to use. With PAD, all resource packs are hosted and provided on Google Play, so you don't need to use a content distribution Network (CDN) to deliver game resources to your players. Play Asset Delivery uses resource bundles, which consist of resources (such as textures, shaders, and sounds) but do not contain executable code. With Dynamic Delivery, you can customize how and when individual resource bundles are downloaded to the device according to three distribution modes: install-time distribution, fast-follow distribution, and on-demand distribution.Copy the code

Android Studio provides a way to build a pad. Now that we’ve used APK transformation, we’ve abandoned the integrated environment that Android Studio provides, so how do we build a Pad ourselves?

This article introduces how to use the command of the pad module, the end of the article provides the tool used in this article & Python script source

Google Android App Bundle(AAB)

Need tools

  • Bundletool – all – 1.6.1. Jar

    Bundletool. jar is a tool that Google provides to generate and test aAbs and is used in gradle packages.

    How to obtain github: github.com/google/bund…

    Detailed documentation & method of use: developer.android.com/studio/comm…

  • aapt2

    Aapt is an Android Asset Packaging Tool.

    ANDROID SDK: $ANDROID_SDK/build-tools/30.0.3/ AAPT2

    Access Google maven: dl.google.com/dl/android/…

    Detailed documentation & method of use: developer.android.com/studio/comm…

  • Apktool_2. 5.0. The jar

    Decompile the Android APK tool.

    How to obtain github: github.com/iBotPeaches…

  • android.jar

    Android Framework, which provides system resources and apis.

    ANDROID SDK: $ANDROID_SDK/platforms/android-30/android.jar

  • d8

    Compile Java bytecode to dex bytecode

    ANDROID SDK: $ANDROID_SDK/build-tools/30.0.3/d8.bat

    Detailed documentation & method of use: developer.android.com/studio/comm…

Build a pad

  • Pad Directory Parsing

    Androidmanifest.xml is used to determine the nature of the module. Androidmanifest.xml is used to determine the nature of the module. Androidmanifest.xml is used to determine the nature of the module. So can we build an identical directory structure and just plug it into AAB?

    After testing, we found that the following files are required in the build (assets are not necessary, but are necessary because we want to expand the resources)

    Heavy Exercises ── Heavy Exercises ─ heavy ExercisesCopy the code

    This directory should be familiar from the previous article. It is a simplified version of the materials required before building base.zip (minus some unnecessary folders). In this case, we will build the original directory structure and source materials

    Pad/Exercises ─ Assets Exercises ─ AndroidManifest.xml Exercises ─ classes.dexCopy the code
  • Build AndroidManifest. XML

    Androidmanifest.xml is the file that determines the nature of the module. You can create your own Androidmanifest.xml based on the configuration information provided by the pad, or you can copy it automatically created in Android Studio. It goes something like this:

    <? The XML version = "1.0" encoding = "utf-8"? > <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:dist="http://schemas.android.com/apk/distribution" android:isFeatureSplit="true" split="$padName" package="$applicationId"> <dist:module dist:instant="false" dist:title="$padName"> <dist:delivery> <dist:install-time/> </dist:delivery> <dist:fusing dist:include="true"/> </dist:module> </manifest>Copy the code

    Split,dist:title: is the name of the module.

    Package: the package name must be the same as that of APK; otherwise, the package will fail to compile

    Install-time resource packages are distributed when users install applications. These resource bundles are provided as split APKs, which are part of the APK set. They are also called “up front” resource bundles; You can use these resource bundles immediately when the application starts. These resource packs increase the size of the apps listed on the Google Play Store. Users cannot modify or delete these resource bundles.

  • Build dex

    Generate R.java from androidmanifest.xml

    aapt2 link --proto-format -o R_base.apk -I android_30.jar --min-sdk-version 19 --target-sdk-version 30 --version-code 1 --version-name 1.0 --manifest androidmanifest.xml --auto-add-overlay -- Java JavaCopy the code

    Compile R.java from javac

    Javac-source 1.7 -target 1.7 Java \wang\i333\pad_demo\ r.javaCopy the code

    Dex is generated from D8

    d8 java/wang/i333/pad_demo/R.class
    Copy the code
  • Build assets

    Get the assets directory by clipping from assets in base or copying from elsewhere

Build a pad. Zip

After the above steps, we will have one

Pad/Exercises ─ Assets Exercises ─ AndroidManifest.xml Exercises ─ classes.dexCopy the code

You can extract classes.dex and Androidmanifest.xml into a template and change the package name in androidmanifest.xml every time you copy it. Then you don’t need to build dex every time, you just need to change the assets folder every time.

Build these directories as pad.zip. You don’t need to create folders that don’t exist. Skip the construction steps and read the previous article.

Generate aAB +pad package

From bundletool we get a base.zip. This article gets a pad.zip

Java-jar bundletool-all-1.6.1.jar build-bundle --modules=base.zip,pad.zip --output=pad_demo.aabCopy the code

–modules: Package multiple modules into aAB.

test

Skip the test steps and read the previous article.

You can also parse to see what modules are in aAB

Jar validate --bundle pad_demo.aabCopy the code

Get tools & source code

Github.com/37sy/build_…

Source code to provide Windows executable tools, with bat script can be directly on the computer operation.

Web online conversion tools will also be provided in the future, so stay tuned…

conclusion

Students who have problems or need to communicate in the process can scan the TWO-DIMENSIONAL code to add friends, and then enter the group for problems and technical exchanges