Unity packages AAB and installs it on your phone with one click

It is very easy to build AAB packages in Unity, just check Build App Bundle (Google Play) in buildsettings.

Here we focus on the issue of one-click installation of the AAB package to the mobile phone for testing.

When installing AAB on a mobile phone, the most critical issue is environmental issues

installation steps:

1. The computer has installed the java environment, jdk, sdk, ndk and other complete sets. If you can create the package, this step will definitely be no problem.

2. Add adb.exe in the sdk to the environment variable Path; (adb.exe is in the SDK/platform-tools directory), edit the environment variable Path, and add the adb.exe path to the Path.

3. Download bundleTool.jar and put it in any directory. Download address: https://github.com/google/bundletool/releases

4. Create a new environment variable, variable name: BUNDLETOOL_PATH variable value: directory of bundleTool.jar

5. Turn on the developer mode on your phone and connect it to the computer using a data cable.

6. Open the debugging tool monitor.bat in the sdk/tools directory. You can see the mobile phone running log indicating that it can be installed on the mobile phone.

7. Make a copy of the keystore used for packaging, which will be needed during installation.

8. Write a bat script

set AppName=#AppName
set BundletoolPath=%BUNDLETOOL_PATH%
set CurPath=%cd%
set AabPath=%CurPath%\%AppName%.aab
set OutapksPath=%CurPath%\%AppName%.apks
set KeystroePath=%CurPath%\#KeystroePath
set KeystroePass=#KeystroePass
set AliasName=#AliasName
set AliasPass=#AliasPass

echo "CurPath": %CurPath%
echo "BundletoolPath": %BundletoolPath%
echo "AabPath": %AabPath%
echo "OutapksPath": %OutapksPath%
echo "KeystroePath": %KeystroePath%
echo "KeystroePass": %KeystroePass%
echo "AliasName": %AliasName%
echo "AliasPass": %AliasPass%

echo "create apks start......:"
java -jar %BundletoolPath% build-apks --bundle=%AabPath% --output=%OutapksPath% --ks=%KeystroePath% --ks-pass=pass:%KeystroePass% --ks-key-alias=%AliasName% --key-pass=pass:%AliasPass% --connected-device
echo "create apks end......:"
echo "install apks to phone start......:"
java -jar %BundletoolPath% install-apks --apks=%OutapksPath%
echo "install apks to phone end......:"

pause>nul 

in:

Replace #AppName with the name of your own app.

#KeystroePath is replaced with your own keystore path,

#KeystroePass is replaced with ksystore password,

#AliasName is replaced with the alias name in the keystore.

#AliasPassReplace with your own Alias ​​password

9. Put AAB, keystore, and the written bat file into the same folder, double-click bat, and you can install it directly to the phone.

Guess you like

Origin blog.csdn.net/qq_39940718/article/details/133360565