How to Install Google Apps without Custom Recovery (Learn to Manually Install GApps in Any Chinese/Non-Global Device)
This article is intended to highlight certain factors regarding the mobile device, by providing a more elaborate explanation to the complexities of its inner workings. This is a topic that most have probably never taken into consideration, but it is my hope that, while although it may seem a bit overwhelming initially, that the information could perhaps become of some relevance for both the average user, as well as those who are more technologically inclined if the circumstances ever arise.
The Cellular Devices in Twenty First Century:
In today's world, cell phones are an essential part of individuals life, so much so, that it would be safe to say that alternative methods of acquiring information have become obsolete. Cellular devices have evolved immensely from their exclusive basic texting and calling features. Not only are they a source of accessing numerous social media platforms, streaming services, and applications, but they have also transformed the traditional education system to a means of virtual learning, and enabled people to manage daily operations of a business from the comfort of their home.
Behind the Story:
One day I was given a request to restore a Samsung On5 (2016), that was subsequently damaged after a relative of mine dropped it into a hot bowl of noodles while eating dinner one evening. My focus is to reiterate the issues I encountered specific to its operating system, along with the processes I implemented in order to attain a resolution.
Fortunately, the hardware got repaired at a local shop, and I was able to power the device back on and charge it successfully, but while I was verifying aspects of its software/hardware performance, I noticed that the "about phone" section displayed "android version 6.0.1". This is a significantly older version in comparison to the current update, which triggered my curiosity to confirm the latest firmware available by searching based on the model number. I was only able to install Android 8.0.1, and although it was by no means current, it was better than the prior existing version.
I instantly flashed the device, anticipating familiarity of what would appear on the main startup screen, but I was caught off guard when I noticed that there weren't any of the core google applications such as Google Play Store, Google Play Services, Google Services Framework etc. Without these fundamental services, the phone is insufficient.
Significance of Google Apps:
It is important to be cognizant of the following in order to identify obstacles that could transpire in the absence of google applications.
- Google Services Framework is a framework essential for the operation of all google apps.
- Google Play Services is a supportive application which ensure security and privacy through credential authentication, storage management, implementation of QOS (Quality of Service) and automatic updates and upgrades.
- Google Contact Sync Adapter is used to keep the stored contacts up to date with the google servers.
- Google Account Manager (as its name suggests) is responsible to handle logged-in accounts and fetching account's data.
- Google Play is a digital storefront for various types of media such as apps, games, music, movies, and e-books.
Initial Attempts:
It became apparent that the Android I had been exploring was not actually a global variant, but rather a Chinese variation of On5 (2016) instead. Google's applications are not used throughout the Chinese market, and are substituted by Baidu Apps in its firmware, I.E. Baidu Location, Baidu Search etc. The desire for these applications outweighs any potential privacy concerns that users may experience. Considering the fact that there doesn't exist an official release of firmware with GApps specific to this scenario, I had the notion of either altering components of the currently installed firmware, or flash a pre-modified firmware to get GApps built in.
I figured that through "Custom Recovery", I could flash open-GApps package on the device, which would provide all variations of GApps for all android versions and architectures in a flashable zip format. I was alarmed to discover that this was not a viable option, so I purchased a pre-modified ROM of the device in which the developer claimed that it contained built-in GApps. Upon flashing that ROM, I quickly learned that it was structured around Android 7.0 with GApps, but required an update to Android 8 afterward, which is definitely not a practical streamlined solution. Lastly, I attempted to gain direct root access to the phone, which is relatively simple to accomplish on Android 8, but it ended up being a tedious process.
After several failed successes, I eventually gained root access through an older version of "Magisk (V18.0)", finally allowing me to reach a level of satisfaction. This contentment was short lived though, when I was unable to flash a custom zip package using root privileges. Despite the fact that I had multiple tools at my disposal, such as FlashFire, Rashr, Flashify and Flash Gordon, they all proved to be a failure. Having enough repetition of disappointments, I settled on engraving GApps manually to Android 8.0.1's official firmware by extracting and placing all GApps files to their required directories and applying correct permissions under ownership of mandatory users and groups.
I specifically used Open-GApps Nano package for android8.0.1 and structured its directory of applications properly according to their destination under "system" partition. Afterward, I configured ADB (Android Debug Bridge) interface, mounted system partition as read/write, and started pushing all directories to their respected locations. Some went to /system/app, while others directed to /system/priv-app. Similarly, the "framework" files to the "framework" folder, and the files about "permissions" to /system/etc. Then I applied correct permissions, users and groups to all files and issued the "reboot" command. Upon restarting the phone, the Samsung logo lingered without ever completing the rebooting process. The only method remaining to solve this matter was to flash its official firmware from scratch, which resulted in all of my previous efforts to surmount to, well, unfortunately, absolutely nothing.
Approach That Worked:
Determined to keep persevering with this cumbersome matter, I downloaded the following applications for Android 8.1.0 from APK Mirror:
- Google Services Framework.
- Google Account Manager.
- Google Play Services.
- Google Play Store.
- and Google Contact Sync Adaptor.
Then, I installed all of these APKs on the phone via "ADB install" command, but multiple error messages kept appearing, such as "unfortunately Google Services Framework and Google Play Services have stopped working".
With super user access, I launched "ADB shell", mounted "system" partition as Read/Write, and navigated to /data/app. This is the directory that contains all user-installed applications. Since I previously analyzed the directory structure of google apps through open-GApps package, it gave me the capacity to properly name and transfer the recently installed google apps to their corresponding locations.
After making these various alterations, I re-mounted the "system" partition back to RO (Read-Only) state, and again issued "reboot" command to the phone. I was delighted when it restarted appropriately, but on the contrary, I was hit with an alert when trying to access the Google Play Store. It read, "Couldn't sign-in, there was a problem communicating with the Google Server". The apps were unable to successfully connect properly because communication to the server was also blocked with the Chinese firmware. It wasn't until I made changes in Android's main host file, that I could finally sign in without being presented with an error. The following sections provide step-by-step instruction to duplicate the exact procedure discussed throughout this guide.
Prerequisites:
- A rooted Android device without GApps. It was Galaxy On5 (2016) SM-G5520 in my case.
- A Windows PC with ADB configured.
- A high-quality USB cable for your phone.
- Appropriate flashing tool according to your device's manufacturer, I used "Odin", which can be used on all Samsung mobile devices.
- Manufacturer's USB drivers, in my case I used "Samsung USB drivers". Yours could be different.
- Official stock ROM of your device which must have the ability to root. For my phone, it was Android 8.0.1 (SM-G5520_CHC_G5520ZCU1CRK1).
- An applicable rooting tool according to your device, I personally accomplished this with the help of Magisk Manager and Magisk patched boot image.
- Core Google Apps packages (listed in the above section) for your phone's Android version in APK format.
- Tons of patients!
Steps to Follow:
Make sure that your phone's battery is at least 50% charged before jumping in the following process.
- First of all, flash the updated stock firmware if it is applicable, and complete the required steps to root your device after setting it up from first boot.
Note1: I am not going into deep detail on the rooting process, because it varies from model to model, and discussing each and every rooting solution does not coincide with the scope of this article, but if you have read everything up until this point, you probably already have an idea how to complete this task.
Note 2: For the device being used throughout my discussion, Samsung Galaxy On5 (2016), containing the model number SM-g5520, you can use Magisk (Version 18.0) with "patched boot image" method to gain root access. You should refuse updating Magisk manager to a later version, otherwise it will break the root chain.
- Enable "Developer Options" by Tapping build number 7 times on "About Phone" screen.
- Go to developer options under settings and enable "USB Debugging".
- Connect the phone via USB cable to your computer. You'll see a confirmation prompt regarding USB debugging connection, Check "Always Allow" box and tap OK. Also enable "MTP (File Transfer Mode)" from notification shade, so that it is possible to access the phone's storage from the computer.
- Open command prompt on your computer and type "adb devices" without the quotes and hit enter. If you are seeing the serial number of your device, then the connection is successful, and you are good to go.
- Now it's time to install all of those APKs which you've obtain from APKMirror (or any similar source). It is your choice whether you install them using ADB commands or copy all of the downloaded files to internal storage and install from the file manager on the device itself. I prefer installation via ADB install command. In case of continuous error pop-ups, the "ADB install" method will be quite beneficial. If the file is present in the current directory, from where you are running android debug bridge, then the file name would be enough, otherwise you have to enter the complete path of your APK file. It may look something like the following example, "adb install C:\user\YourUser\desktop\file.apk". For your reference, I am mentioning the full names of APKs below where only the version number may be different on your end:
- com.google.android.gsf-V8.1.0.apk = Google Services Framework.
- com.google.android.gms-V21.48.57.apk = Google Play Services.
- com.google.android.gsf.login-V7.1.2.apk = Google Account Manager.
- com.android.vending-V29.0.15.apk = Google Play Store.
- com.google.android.syncadapters.contacts-V8.1.0.apk = Google Contacts Sync Adapter.
Note: You may experience lots of "application stopped" errors after installing these apps. Don't worry, just continue to the next step. We'll fix it!
- Now you need to launch ADB shell with superuser privileges. Type "adb shell su" and press enter. You should see another prompt by root manager you used, asking for confirming root access to shell. Choose allow access to continue.
Note 1: If no prompt appears, then you need to manually allow root access to shell by going to root manager on your phone (Magisk Manager in my case).
Note 2: On some Samsung devices, it is possible that "Samsung Members" application will ask to allow root access instead of shell, which happened in my case. If it is happening with you, don't worry, simply allow access to continue.
- This is where we need to convert recently installed applications from user-apps to system-apps. To achieve this, you need to mount the system partition with read/write permissions so that you can make changes inside its directories. Type "mount -o rw, remount /system" in the shell interface and press enter.
- Navigate to destination directory for user-installed apps by executing command "cd /data/app". If you check the content of this directory by "ls" command, you'll see folders for all apps you've installed in previous steps by the titles of their package names I.E. com.android.vending, followed by a unique ID.
- At this point, you need to move directories of the recently installed 5 apps to system apps location in order to allow the operating system to recognize them as "system apps". Type "mv" followed by directory name and path to the new destination.
Note: As I mentioned above, the name of each directory contains a unique ID at the end. Typing every name with its correct ID is difficult, therefore, most of you might know that pressing the "Tab Key" while writing the name of a file/folder performs auto-complete function in shell interface. This is what you need to do here E.G. after typing com.google.android.gsf.login, press "tab key" and it will automatically fill the rest of the name of the intended directory. Through this way, you don't need to type the longer IDs manually each time while moving these directories.
I am pasting exemplary commands for all directories (without their unique IDs) below with correct arguments:
- mv com.google.android.gms-app-ID== /system/priv-app/GmsCore.
- mv com.google.android.gsf.login-app-ID== /system/priv-app/GoogleLoginService.
- mv com.android.vending-app-ID== /system/priv-app/Phonesky.
- mv com.google.android.gsf-app-ID== /system/priv-app/GoogleServicesFramework.
- mv com.google.android.syncadapters.contacts-app-ID== /system/app/GoogleContactsSyncAdapter.
- For Android's operating structure, it is important that all files of apps inherit permissions "644" and folders with permissions "755". Secondly, ownership of app's installation directories should be set to system user and group. Fortunately, when we move anything from user data partition to system partition, appropriate permissions and ownerships apply automatically. Considering this fact, there may not be an option to make these changes manually, but in any case, if you need to change permissions you can make use of "chmod" command followed by file/folder name E.G. chmod 644 base.apk. Similarly, if you need to change ownership, the "chown" command comes into play E.G. "chown -R system:system /system/app/GoogleContactsSyncAdapter", Where "chown" = "change owner", -R = recursive, "system" before ':' sign = type of user you want to assign as an owner, "system" after ':' sign = type of group you want to assign as an owner, and complete it by the path of directory in which you want to change ownership.
- At last, it's time to restart the device and witness your progress. Type "reboot" and hit enter and continue monitoring the screen until it turns back on.
Now you have fully intergraded GApps on the device and they should be functioning as expected, although it wasn't the case for me due to the host blocking. If you are experiencing interruptions in connecting to the google server, then read ahead for further steps to overcome this issue.
Unblock Access to Google's Servers:
Note: The following process can be done with any root file explorer on your phone as well, but as mentioned earlier, I always prefer command-line to achieve such quite complicated tasks, so this is how it will be explained moving forward.
- Connect the phone again via USB and confirm ADB connection with "adb devices" command.
- Type "adb shell su" to open up the shell interface with superuser.
- Mount system partition as read/write by typing "mount -o rw,remount /system".
- Take the backup of the main host file to "Download" directory on internal storage in order to edit it later. Execute "cp /system/etc/hosts /sdcard/Download/hosts.backup".
- Open/edit file "hosts.backup" on your computer with notepad from the phone's internal storage> Download. Make a second copy of this file before editing for back-up purposes if you really want to be more secure.
- Empty all content inside the file, and copy/paste the following 2 lines:
127.0.0.1 localhost
#127.185.66.4 android.clients.google.com
- Save the file, rename it from "hosts.backup" to "hosts (without any file extension)". Now you should have 1 file named "hosts" in the "Download" folder within the internal storage on your phone.
- Go back to ADB shell interface, which should already be opened on your computer. Then you need to replace the system's main hosts file with the modified hosts file contained in "Download" folder. Just type "cp /sdcard/Download/hosts /system/etc/" and hit enter with confidence!
- Once more, as a final step, restart the device by issuing the "reboot" command and wait for the magic to happen!
- When your phone boots up, verify your success by opening any app, Google Play Store for instance, and you'll be greeted by Google's Account Sign-in screen. Yeah! Hurrah!
Concluding Remarks:
I greatly appreciate you absorbing all of your interest and attention into reading such a detailed overview of my experiences and personal achievements to conquer each and every barrier that came my way throughout this process. If you carried out each task accurately, then I assure you that reciprocation of immense relief and happiness has been given back to me. I aspire to present my efforts as a form of influence that encourages analytical aptitude, technical competency, and a level of integrity that allows others to share similar endeavors Comparable to my own. In hopes of circulating beneficial knowledge, please disperse this content to those around you, and standby for future material discussing various topics relevant to technology. Take care, stay safe, and farewell for now!
Credits:
- Originally experienced and written by Abdullah Zubair in the Urdu language.
- It was translated into English by Abdullah Zafar.
- Was proofread and edited by Britney Montgomery.
- Final formatting including but not limited to internal/external linking, divisions, visual look and punctuations fixes by Arslan Anwar and Mehwish Abdullah.
- 6703 reads
Your Help Required to Keep The Lights On!
Satisfied with the provided Services?
Show your LOVE and Secure BHp's Future.
Every single Penny helps, counts and means a lot
And will be spent to Deliver Even More.
Introducing Free Membership of BookShare for Pakistanis
Popular on BHP
-
Type: softwareTotal views: 1,039,833
-
Type: softwareTotal views: 253,559
-
Type: softwareTotal views: 197,729
-
Type: softwareTotal views: 146,501
-
Type: softwareTotal views: 128,871
-
Type: softwareTotal views: 83,352
-
Type: softwareTotal views: 69,410