WSA-Community / WSAGAScript

Scripts to install Google Apps into a WSA image. Plus optional root
The Unlicense
3.59k stars 3.53k forks source link
android google-apps linux windows windows-11 wsa wsl2

WSA GApps Script

Required WarningsYouTube TutorialInstallation procedureUninstallation procedureGaining Root AccessTelegram Group

Required Warnings

This project is Work-In-Progress

This project is being updated without schedule (though frequently). This README might not be completely clear right now, it will be fixed ASAP.

As for potential questions - please open Discussions instead of Issues.
Issues are needed in cases if you have an actual issue that prevents you from using this project.

Legal Warnings

By using the tools (scripts, but not limited to) provided by this project, you agree with the terms of Unlicense License, which states that "THE SOFTWARE IS PROVIDED "AS IS"".

To end user this serves as a warning, though we currently don't have any explicit confirmations - such way of installing Google Services and Google Play Store may potentially be in a legal gray area.

Copyright notices

Any product or trademark referenced in this document (or project as whole) belongs to their respective owners. No copyright infringement is intended.

YouTube Tutorial

As a temporary measure and additional information (especially if README remains unclear, @ADeltaX provides a video-tutorial hosted on YouTube

[![How to install Google Apps (Play Store) on WSA (Windows Subsystem Android)](http://img.youtube.com/vi/rIt00xDp0tM/0.jpg)](http://www.youtube.com/watch?v=rIt00xDp0tM 'How to install Google Apps (Play Store) on WSA (Windows Subsystem Android)')

Click on the image to see the video

Installation procedure

Install Windows Subsystem for Linux (Version 2)

Q & A for WSL Installation

If you have never used WSL, please do check the following:

Fastest way to check your build version is to run winver command in Windows Search or via "Run..." (Right-click the Start button to access "Run...")

Because of the way Android as an operating system is built - specific tools to do the modifications that we are doing are only available on Linux-based OSes. The fastest way to get access to these tools is via WSL.

How to install WSL

Your PC may restart several times when downloading and installing required components. After that - follow installation wizard instructions to proceed. If you have any questions, official documentation from Microsoft for WSL will help you.

Microsoft Docs: Installing WSL

Microsoft Docs: Set up and best practices

How to convert WSL1 to WSL2 (and manual installation)

If you have trouble installing WSL2 with wsl --install in general - follow this instruction from Microsoft.

Microsoft Docs: Manual installation steps for older versions of WSL

If you have already used WSL, have trouble installing with wsl --install or for some reason have received a WSL1 version installation, this section is for you.

Follow these steps:

Install unzip, lzip

For now, we are assuming that you have went with default installation (Ubuntu), terminal commands will be provided for Ubuntu. Commands provided for the most part will work for other Linux Distributions but there may be some that use other package managers. Check how to correctly install applications for your chosen distribution on the internet.

Run following in the WSL Terminal (If you are unsure what is WSL Terminal, refer to the video, Microsoft Docs, or search Ubuntu in your start menu to be sure):

Attention! For new users who have never used Linux Terminals - when you are being asked for your password (which you've set up when installed WSL) - it will NOT be displayed in the terminal as part of security measures. You should enter it blindly and then press enter. If password was entered incorrectly system will give you two more attempts, after which you will need to run the command again and try entering password again.

sudo apt update
sudo apt install unzip lzip

We have checked availability of updates and requested installation of two packages which are required for execution of scripts provided by this project. They may be already present at your installation, but it is better to check anyway.

Prepare folder structure

For the sake of simplicity, create a folder in the root of C Drive, so you will have C:\WSA\. You may use other location if you would like, be sure to adjust commands below for new location.

Attention! The folder where you will place the files which we will be downloading is going to become an installation folder. DO NOT delete that folder!
Attention! At the time of last update for this README, attempt to run scripts if they are located in path that contains spaces (like "Zulu Storage" in D:\Zulu Storage\WSA) will result in an error. Be sure to use paths with no spaces as long as fix have not been implemented.

Hint: You can also open any folder (even those that are located within Linux WSL Filesystem, by typing explorer.exe . (Yes, with the dot) in the WSL Terminal, to move files around.

Download Windows Subsystem for Android™️ Installation Package

Download

As we need to modify installation files, we cannot download WSA from the Microsoft Store. To download it directly we will use this service

Use settings:

Click the checkmark, and locate file which has size of approx. ~1.3GB (usually at the bottom of the page) and has .msixbundle extension.

Click the filename to begin downloading (or copy the download link). You may be warned by your web-browser that "The file cannot be downloaded securely". Disregard the warning and force the download (use buttons like "Keep anyway" or similar, depending on your web-browser)

Save the file at our prepared directory C:\WSA\

Extract

Do not close this folder - we will return here to collect *.img files.

Download "GApps" via OpenGApps Project

To install Play Store, we need to get it from somewhere. Use OpenGApps.

Use settings:

For the time being save the .zip file at C:\WSA\gapps-zip-file-name.zip. Do not extract it.

Clone this repository and populate the directories

As we have used C:\WSA, you will be able to use Windows Explorer to move files around.

Reminder: commands provided are for Ubuntu

Attention! To be sure that you can access your Windows filesystem from inside of WSL, you can run cd FolderName to change to another directory and ls to list what files and folders you have there. Typically, Windows Filesystem is available by "/mnt/$DriveLetter/", so /mnt/c/Users will be your Windows C:\Users

cd /mnt/c/WSA
git clone https://github.com/WSA-Community/WSAGAScript

Wait for the command to finish running.

At the Extract step (in Download Windows Subsystem for Android™️ Installation Package) of this Guide we have got a folder that contains four *.img files which are product, system, system_ext and vendor. Move those files into C:\WSA\WSAGAScript\#IMAGES

Then issuing ls /mnt/c/WSA/WSAGAScript/\#IMAGES via WSL terminal should give the list of the following files:

product.img  system_ext.img  system.img  vendor.img

We also have C:\WSA\gapps-zip-file-name.zip. Copy this .zip file into C:\WSA\WSAGAScript\#GAPPS. Do not extract it, just move the file.

Issuing ls /mnt/c/WSA/WSAGAScript/\#GAPPS via WSL terminal, you should get something similar to the following:

open_gapps-x86_64-11.0-pico-20220503.zip  output  product_output

Final preparations

Change architecture

If you are using this project on a device with ARM architecture (e.g., Qualcomm Snapdragon), please edit VARIABLES.sh and set the correct architecture. Hint is in the file.

Set executable permissions for the scripts

You should still be in the same directory within the WSL Terminal, if not use cd /mnt/c/WSA/WSAGAScript to get back. Set executable permissions for the scripts:

chmod +x *.sh

Verify that your scripts are executable by running ls -l and checking that you have -rwxrwxrwx at the start of lines that contain files: VARIABLES.sh, apply.sh, extend_and_mount_images.sh, extract_gapps_pico.sh, unmount_images.sh.

Running the scripts

Make sure you're in the same directory as in the step before, the run:

./extract_gapps_pico.sh
sudo ./extend_and_mount_images.sh
sudo ./apply.sh
sudo ./unmount_images.sh

Copy the edited images

After successful execution, you can now copy edited images from C:\WSA\WSAGAScript\#IMAGES back to C:\WSA\MicrosoftCorporationII.WindowsSubsystemForAndroid_1.8.32822.0_neutral___8wekyb3d8bbwe\WsaPackage_1.8.32822.0_x64_Release-Nightly (example, the folder from where you have taken the images).

Registering the edited Windows Subsystem for Android™️ Installation Package

Where path-to-extracted-msix, use path from "Copy the edited images" section (right above) as example.

WSA will install with GApps, make sure to sign in to Play Store and install "Android System WebView" or most apps will crash without that component.

Uninstallation procedure

Done.

Gaining Root Access

You can get root access by replacing the kernel. (This step is no longer required to sign in GApps.)

(ADB SHELL ROOT WITH su)

Copy the kernel file from this repo (in misc folder) and replace the kernel file inside the Tools folder of your extracted msix (make sure WSA is not running, use Stop button inside WSA Settings, and close settings).

Kernel files inside misc are named for their respective architectures, do not forget to rename the file you took to kernel before placing it back into Tools.

This will allow you to use su inside the adb shell. Enter into the adb shell and run the following commands:

su

You are now root.

Procedure to add files to WSA

It is possible to add files to WSA (Windows Sybsystem for Android) through WSL. As an example, we will install busybox and bash.

First, turn off WSA:

Then open a WSL terminal:

cd /mnt/d/WSA/...MicrosoftCorporationII.WindowsSubsystemForAndroid_versionnumber_neutral___identifier...

# Temporarily extend the "system" filesystem to allow adding things
e2fsck -f system.img
sudo resize2fs system.img 1280M

# Mount "system" in read-write
sudo mount system.img /mnt/system

Example to add busybox and bash

Check the most recent binaries for x86_64-linux; at the time of writing: https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/

cd /mnt/system/system
sudo mkdir xbin
cd xbin
sudo wget https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox
sudo chmod 755 busybox
for i in `./busybox --list`; do sudo ln busybox "$i"; done

# We will use the debian bash executable
sudo mkdir temp
cd temp
sudo wget http://http.us.debian.org/debian/pool/main/b/bash/bash-static_5.1-2+b3_i386.deb
sudo dpkg-deb -R bash-static_5.1-2+b3_i386.deb tmp
sudo chmod 755 tmp/bin/bash-static
sudo cp tmp/bin/bash-static ..
cd ..
sudo rm -r temp

# Yet another bash executable...
sudo wget https://github.com/robxu9/bash-static/releases/download/5.1.016-1.2.3/bash-linux-x86_64
sudo chmod 755 bash-linux-x86_64

# Unmount system filesystem
cd
sudo umount /mnt/system

# Shrink the system filesystem to minimize its size as much as possible
e2fsck -f system.img
sudo resize2fs -M system.img

Testing the installation

Start Windows Sybsystem for Android (e.g., open Windows Sybsystem for Android Settings and press the button close to Files).

Open a CMD with path to adb.

adb connect 127.0.0.1:58526
adb shell
su
export PATH=$PATH:/system/xbin
type vi

Kernel source

Currently known issues