[SCRIPT] [2021-01-30] [v2.9] Universal Android Debloater

FourSilver

Member
Jan 11, 2021
19
3
3
Hi,

Thanks for your help! :)



I've added more detailed instructions. You have to run this script in the parent directory of the UAD repository/folder because by default it seeks for the lists in ./universal-android-debloater/lists
My pleasure!

I repeated the procedure with the script in parent directory; in this case, the home directory (~/)

When I run the script from the prompt as 'sh bash' in the parent directory (where 'bash' is the name of the file, as downloaded from the repository), the following is returned from the command line:

bash: 5: cannot open : no such file

(BTW: The response is the same when the script is run using './bash')

When I run the script as 'bash bash' (where the latter/second 'bash' is the name of the downloaded file), the following response is issued:

bash: line 10: No such file or directory

What is the proper syntax for running the script?
 
Last edited:

w1nst0n_fr

Member
Dec 27, 2019
44
65
38
gitlab.com
Oh! Okay... I don't know why the file is called like that. It shouldn't be called bash at all. That's the first issue. Bash is a linux internal command. I renamed it (remove_duplicates.sh).

I also modified a little bit the script so make sure to use the last version.

1) Download the repository (or clone it with git if you plan to do a pull request) and extract the zip somewhere (let say /home/username/Documents)

2) Download the snippet and save it to /home/username/Documents

3) Put your package list in the same directory

4) Open a unix terminal and from /home/username/Documents type :
Bash:
 sh remove_duplicates.sh yourlist.sh
There should be no problem anymore. :)
 

FourSilver

Member
Jan 11, 2021
19
3
3
4) Open a unix terminal and from /home/username/Documents type :
Bash:
 sh remove_duplicates.sh yourlist.sh
There should be no problem anymore. :)
Ah! I somehow missed that it required an argument. The output is the same as I reported earlier (i.e. no such file); I imagine it is because I have not listed the yourlist.sh file.

Seeing that I have a device that is not currently present in the list of devices recognized by the Debloater tool (i.e. Atom XL), how do I create the content that goes into the yourlist.sh file?
 
Last edited:
Apr 3, 2019
17
8
3
Hopefully some simple questions. I notice that this tool is using pm uninstall to remove the apps, and then rm -rf to remove the apk and folder if using root. I think if using root that both actions are performed. Other tools (like https://forum.xda-developers.com/t/...ebloated-extra-features.3793694/post-83490679) just remove the folder.

Is there a benefit to using either technique?

I would guess the just deleting the folder could potentially leave some orphaned directories and databases, but maybe everything in Android is all stored in one location?

If I use a script which performs rm -rf from within TWRP before first start of the device (after new flash of ROM), would this remove the apps before they are installed, or have the device manufacturer/ROM builder already installed these apps within the firmware?

I am planning to go back to stock ROM on my device (Samsung A320FL), and looking for a good debloat tool, this seems to be the best I have found!

Thanks
 

kurtn

Senior Member
Jan 28, 2017
3,773
1,582
233
Small town in Bavaria
Hopefully some simple questions. I notice that this tool is using pm uninstall to remove the apps, and then rm -rf to remove the apk and folder if using root. I think if using root that both actions are performed. Other tools (like https://forum.xda-developers.com/t/...ebloated-extra-features.3793694/post-83490679) just remove the folder.

Is there a benefit to using either technique?

I would guess the just deleting the folder could potentially leave some orphaned directories and databases, but maybe everything in Android is all stored in one location?

If I use a script which performs rm -rf from within TWRP before first start of the device (after new flash of ROM), would this remove the apps before they are installed, or have the device manufacturer/ROM builder already installed these apps within the firmware?

I am planning to go back to stock ROM on my device (Samsung A320FL), and looking for a good debloat tool, this seems to be the best I have found!

Thanks
I have the a3 2017 and I'm happy with none root debloating.
 

w1nst0n_fr

Member
Dec 27, 2019
44
65
38
gitlab.com
I imagine it is because I have not listed the yourlist.sh file.

Seeing that I have a device that is not currently present in the list of devices recognized by the Debloater tool (i.e. Atom XL), how do I create the content that goes into the yourlist.sh file?
Yes, you need to pass a file (containing a list of packages) as argument of the script.

You can pass the list of all the packages of your device.

To generate the list:
Bash:
adb shell 'pm list packages -s' | sed 's/package://g' | sort > myPackageList.txt
Note: Don't forget to add quotes to the packages name in your list. The script which check for duplicates will not work if your list isn't formatted like this :

Code:
"com.samsung.android.provider.filterprovider"
"com.android.cts.priv.ctsshim"
"com.gd.mobicore.pa"
"com.samsung.android.app.aodservice"
"com.android.providers.telephony"
"com.samsung.android.applock"
"com.sec.automation"
"com.android.providers.media"
Then, run the script like this:
Bash:
sh remove_duplicates.sh myPackageList.txt
I've updated the wiki and the snippet description to be more noob friendly ! :)
 

w1nst0n_fr

Member
Dec 27, 2019
44
65
38
gitlab.com
Hi,

I notice that this tool is using pm uninstall to remove the apps, and then rm -rf to remove the apk and folder if using root
The script doesn't work like that. pm uninstall is only performed if you choose the non-root debloat feature. Root debloat only does a rm -rf /path/to/apk in v2.8.4. In 2.9 it will be a systemless debloat for Android 10+ devices (see the release notes for v2.9-temp if you don't understand why)

If I use a script which performs rm -rf from within TWRP before first start of the device (after new flash of ROM), would this remove the apps before they are installed, or have the device manufacturer/ROM builder already installed these apps within the firmware?
(This kind of script will not work on Android 10+ devices)

You can't remove apps on a phone if they haven't been installed in the first place. However, they won't never run as you removed them before the first system boot. So it's okay.

What you can also do is directly modify the ROM flashable zip and remove the apps/apks you don't want so that when you'll flash the ROM the apps won't be installed. @_alexndr unfortunately doesn't provide a ROM for your phone. He maintains custom stock ROMs for Samsung Galaxy S phones and gives a way to easily debloat the ROM. He is a really serious, talented and conscientious developer.
 
Apr 3, 2019
17
8
3
Hi,


The script doesn't work like that. pm uninstall is only performed if you choose the non-root debloat feature. Root debloat only does a rm -rf /path/to/apk in v2.8.4. In 2.9 it will be a systemless debloat for Android 10+ devices (see the release notes for v2.9-temp if you don't understand why)



(This kind of script will not work on Android 10+ devices)

You can't remove apps on a phone if they haven't been installed in the first place. However, they won't never run as you removed them before the first system boot. So it's okay.

What you can also do is directly modify the ROM flashable zip and remove the apps/apks you don't want so that when you'll flash the ROM the apps won't be installed. @_alexndr unfortunately doesn't provide a ROM for your phone. He maintains custom stock ROMs for Samsung Galaxy S phones and gives a way to easily debloat the ROM. He is a really serious, talented and conscientious developer.
Thanks for the reply, that is clear. The official ROM for the A320FL is only Oreo (Android 8) anyway. Pie and 10 have been ported from other devices, and also 3rd party like Lineage, but they all have different problems (H-ROM from @Astrako is definitely the best I have tried, and only a few minor niggles). Right now I was planning to try latest Oreo stock ROM for a period of time and maybe switch again later. I noticed the problem with mounting system as RW when I last tested a 10 ROM, but never caused me enough problems to look into why this didn't work!

Will systemless debloat be used on all devices after V2.9 or will older devices still mount system and delete the APK?

By just deleting the APK folder, do you get any orphan data left over (i.e. in shared storage folders within /data/data?). Maybe if the app is never run then these folders are not created? Would using
Code:
pm clear com.yourapp.packagename
before removing the app clear off any data folders that are remaining? Maybe SD Maid or similar app can find the orphan files afterwards and delete them. Or I guess they are probably only small (especially if you have never used the app) so maybe it is not worth the effort and they are doing no harm?
 

FourSilver

Member
Jan 11, 2021
19
3
3
I've updated the wiki and the snippet description to be more noob friendly ! :)
Support for n00bs is _always_ appreciated! :p

The snippet works! However, after I create an aosp debloat list using the debloat script, I am given the option to physically delete the apks. By electing yes, I get the following error:
Code:
[EXIT TRAP] Hum... something is wrong. Error on line 414

If you think this is a bug. Please report it :)
==> https://gitlab.com/W1nst0n/universal-android-debloater/-/issues
I believe it is because I missed the countdown the first time I was prompted to accept the action on the device. How can I get the prompt again so I can accept the deletions? (I know this is possibly more a Magisk question, but I figured I'd ask...)
 

w1nst0n_fr

Member
Dec 27, 2019
44
65
38
gitlab.com
-------------- New Version (v2.9) --------------

Systemless debloat support. Root features should finally work for all Android versions. Check the full changelog on Gitlab.

Note: The debloat_script.sh is now in maintenance mode and won't receive any more features. The focus is on the developement of a GUI.

-------------------------------------------------------

Will systemless debloat be used on all devices after V2.9 or will older devices still mount system and delete the APK?
You can choose between the 2 methods.

By just deleting the APK folder, do you get any orphan data left over (i.e. in shared storage folders within /data/data)?. Maybe if the app is never run then these folders are not created? Would using pm clear com.yourapp.packagename before removing the app clear off any data folders that are remaining?
Yes, you'll get a bunch of orphan files (apps data, cache, oat files) if the apps already run on your phone.

Performing pm clear only remove app data and cache. It doesn't remove the folders nor oat files (precompiled code of the app) but that's well enough.

v2.9 does this before any root debloat.

Maybe SD Maid or similar app can find the orphan files afterwards and delete them. Or I guess they are probably only small (especially if you have never used the app) so maybe it is not worth the effort and they are doing no harm?
Yes. That's it. It is not worth the effort all the more so SD Maid exists. This is a really good app, made by a nice person on top of that.

I believe it is because I missed the countdown the first time I was prompted to accept the action on the device. How can I get the prompt again so I can accept the deletions? (I know this is possibly more a Magisk question, but I figured I'd ask...)
The error being line 414, you indeed missed the countdown.

In Magisk Manager (last version), click on the shield icon in the dock (at the bottom of the app). Then, allow superuser rights to Shell
 
Last edited:

FourSilver

Member
Jan 11, 2021
19
3
3
-------------- New Version (v2.9) --------------

Systemless debloat support. Root features should finally work for all Android versions. Check the full changelog on Gitlab.

Note: The debloat_script.sh is now in maintenance mode and won't receive any more features. The focus is on the developement of a GUI.

-------------------------------------------------------
The error being line 414, you indeed missed the countdown.

In Magisk Manager (last version), click on the shield icon in the dock (at the bottom of the app). Then, allow superuser rights to Shell
It turns out that I had the rights allowed for Shell in Magisk Manager. Not sure why I could not get another chance...

To address the operator error, I wiped the device and started over. I downloaded version 2.9 and issued bash debloat_script.sh, and I was not prompted for root access. The menu now seems to include options for unihertz and mediatek, although nothing turned up for the former. (Perhaps I missed these earlier?) I was able to create zip files for apks to debloat using the mediatek option, along with the aosp option. I then used Magisk Manager to install these files.

As a check, I installed the de-bloater package from F-Droid, and checked for the presence of com.adups.fota (which is considered malware, according to MITRE.) It is currently no longer on the device.

Thanks for the support!
 

0wdj

New member
Oct 25, 2020
1
0
1
How to completely remove the APK with root?
I got this error when I try to delete chrome

Code:
Clearing app data...

com.android.chrome -->
Exception occurred while executing 'clear':
java.lang.SecurityException: PID 29500 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.android.chrome
        at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4428)
        at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:2100)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:227)
        at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98)
        at android.os.ShellCommand.exec(ShellCommand.java:44)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22135)
        at android.os.Binder.shellCommand(Binder.java:929)
        at android.os.Binder.onTransact(Binder.java:813)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4687)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4408)
        at android.os.Binder.execTransactInternal(Binder.java:1159)
        at android.os.Binder.execTransact(Binder.java:1123)


[EXIT TRAP] Hum... something is wrong. Error on line 226
 
Apr 3, 2019
17
8
3
-------------- New Version (v2.9) --------------

Systemless debloat support. Root features should finally work for all Android versions. Check the full changelog on Gitlab.

Note: The debloat_script.sh is now in maintenance mode and won't receive any more features. The focus is on the developement of a GUI.

-------------------------------------------------------



You can choose between the 2 methods.



Yes, you'll get a bunch of orphan files (apps data, cache, oat files) if the apps already run on your phone.

Performing pm clear only remove app data and cache. It doesn't remove the folders nor oat files (precompiled code of the app) but that's well enough.

v2.9 does this before any root debloat.



Yes. That's it. It is not worth the effort all the more so SD Maid exists. This is a really good app, made by a nice person on top of that.



The error being line 414, you indeed missed the countdown.

In Magisk Manager (last version), click on the shield icon in the dock (at the bottom of the app). Then, allow superuser rights to Shell
Thanks for the reply, this is clear and very helpful. Your hard work on this tool is very much appreciated!