[OnePlus 5T  Questions & Answers] moeq123:
Ah, sorry, my bad. It's been a while for me

since I've modified a ROM.

All this stuff should be contained inside the file

system.new.dat. There is a guide for extracting the .dat file here:

https://xdaforums.com/android/help/extract-dat-marshmallow-lollipop-easily-t3334117/amp/

You might also want to see this:

https://xdaforums.com/general/xda-university/unpacking-editing-packing-roms-img-dat-t3350261/amp/

If you don't want to do this all by yourself

you should check out some scripts. I came across this one f.e.:

https://xdaforums.com/oneplus-3t/themes/flashable-remove-gapps-stock-oos-roms-t3562983/amp/

All it does is removing every google related stuff inside of the system folder of your android.

So, step one should be flashing stock rom, after that, make sure twrp recovery is still there.

If not - flash a custom recovery like twrp. After that flash the removeGapps.zip mentioned in the linked article.

That should be it then.

The code of the script:

#!/sbin/sh
rm -rf /system/app/Books
rm -rf /system/app/CalculatorGoogle
rm -rf /system/app/CalendarGooglePrebuilt
rm -rf /system/app/Chrome
rm -rf /system/app/CloudPrint
rm -rf /system/app/CloudPrint2
rm -rf /system/app/ConfigUpdater
rm -rf /system/app/DMAgent
rm -rf /system/app/Drive
rm -rf /system/app/EditorsDocs
rm -rf /system/app/EditorsSheets
rm -rf /system/app/EditorsSlides
rm -rf /system/app/ExchangeServices
rm -rf /system/app/FaceLock
rm -rf /system/app/FitnessPrebuilt
rm -rf /system/app/GoogleCalendarSyncAdapter
rm -rf /system/app/GoogleCamera
rm -rf /system/app/GoogleContactsSyncAdapter
rm -rf /system/app/GoogleEars
rm -rf /system/app/GoogleEarth
rm -rf /system/app/GoogleHindiIME
rm -rf /system/app/GoogleHome
rm -rf /system/app/GoogleJapaneseInput
rm -rf /system/app/GooglePinyinIME
rm -rf /system/app/GoogleTTS
rm -rf /system/app/Hangouts
rm -rf /system/app/Duo
rm -rf /system/app/HangoutsDialer
rm -rf /system/app/KoreanIME
rm -rf /system/app/LatinImeGoogle
rm -rf /system/app/Maps
rm -rf /system/app/Music2
rm -rf /system/app/Newsstand
rm -rf /system/app/Photos
rm -rf /system/app/PlayAutoInstallConfig
rm -rf /system/app/PlayGames
rm -rf /system/app/PlusOne
rm -rf /system/app/PrebuiltBugle
rm -rf /system/app/PrebuiltDeskClockGoogle
rm -rf /system/app/PrebuiltEmailGoogle
rm -rf /system/app/PrebuiltExchange3Google
rm -rf /system/app/PrebuiltGmail
rm -rf /system/app/PrebuiltKeep
rm -rf /system/app/PrebuiltNewsWeather
rm -rf /system/app/PrintSpooler
rm -rf /system/app/Street
rm -rf /system/app/talkback
rm -rf /system/app/Tycho
rm -rf /system/app/Videos
rm -rf /system/app/Wallet
rm -rf /system/app/YouTube
rm -rf /system/priv-app/AndroidForWork
rm -rf /system/priv-app/BackupRestoreConfirmation
rm -rf /system/priv-app/CalendarProvider
rm -rf /system/priv-app/ConfigUpdater
rm -rf /system/priv-app/ConnMO
rm -rf /system/priv-app/GCS
rm -rf /system/priv-app/GoogleBackupTransport
rm -rf /system/priv-app/GoogleContacts
rm -rf /system/priv-app/GoogleDialer
rm -rf /system/priv-app/GoogleFeedback
rm -rf /system/priv-app/GoogleLoginService
rm -rf /system/priv-app/GoogleOneTimeInitializer
rm -rf /system/priv-app/GooglePackageInstaller
rm -rf /system/priv-app/GooglePartnerSetup
rm -rf /system/priv-app/GoogleServicesFramework
rm -rf /system/priv-app/Hangouts
rm -rf /system/priv-app/HotwordEnrollment
rm -rf /system/priv-app/Phonesky
rm -rf /system/priv-app/PrebuiltGmsCore
rm -rf /system/priv-app/SetupWizard
rm -rf /system/priv-app/TagGoogle
rm -rf /system/priv-app/Talkback
rm -rf /system/priv-app/Velvet
rm -rf /system/priv-app/Wallet
rm -rf /system/tts
rm -rf /system/usr/srec
rm -rf /system/vendor/pittpatt
rm /system/addon.d/70-gapps.sh
rm /system/addon.d/71-faceunlock.sh
rm /system/addon.d/71-gapps-faceunlock.sh
rm /system/addon.d/74-googlecamera.sh
rm /system/addon.d/74-googlegallery.sh
rm /system/addon.d/75-googlegallery.sh
rm /system/addon.d/78-chromebrowser.sh
rm /system/app/Books.apk
rm /system/app/Books.odex
rm /system/app/BooksPhone.apk
rm /system/app/BooksPhone.odex
rm /system/app/BrowserProviderProxy.apk
rm /system/app/BrowserProviderProxy.odex
rm /system/app/CalculatorGoogle.apk
rm /system/app/CalculatorGoogle.odex
rm /system/app/Calendar.apk
rm /system/app/Duo.apk
rm /system/app/Calendar.odex
rm /system/app/CalendarGoogle.apk
rm /system/app/CalendarGoogle.odex
rm /system/app/CalendarGooglePrebuilt.apk
rm /system/app/CalendarGooglePrebuilt.odex
rm /system/app/CalendarProvider.apk
rm /system/app/CalendarProvider.odex
rm /system/app/CarHomeGoogle.apk
rm /system/app/CarHomeGoogle.odex
rm /system/app/CellBroadcastReceiver.apk
rm /system/app/CellBroadcastReceiver.odex
rm /system/app/Chrome.apk
rm /system/app/Chrome.odex
rm /system/app/ChromeBookmarksSyncAdapter.apk
rm /system/app/ChromeBookmarksSyncAdapter.odex
rm /system/app/CloudPrint.apk
rm /system/app/CloudPrint.odex
rm /system/app/CloudPrint2.apk
rm /system/app/CloudPrint2.odex
rm /system/app/ConfigUpdater.apk
rm /system/app/ConfigUpdater.odex
rm /system/app/Currents.apk
rm /system/app/Currents.odex
rm /system/app/DeskClockGoogle.apk
rm /system/app/DeskClockGoogle.odex
rm /system/app/DMAgent.apk
rm /system/app/DMAgent.odex
rm /system/app/Drive.apk
rm /system/app/Drive.odex
rm /system/app/EditorsDocs.apk
rm /system/app/EditorsDocs.odex
rm /system/app/EditorsSheets.apk
rm /system/app/EditorsSheets.odex
rm /system/app/EditorsSlides.apk
rm /system/app/EditorsSlides.odex
rm /system/app/ExchangeServices.apk
rm /system/app/ExchangeServices.odex
rm /system/app/FaceLock.apk
rm /system/app/FaceLock.odex
rm /system/app/Finsky.apk
rm /system/app/Finsky.odex
rm /system/app/FitnessPrebuilt.apk
rm /system/app/FitnessPrebuilt.odex
rm /system/app/FOTAKill.apk
rm /system/app/FOTAKill.odex
rm /system/app/GalleryGoogle.apk
rm /system/app/GalleryGoogle.odex
rm /system/app/GenieWidget.apk
rm /system/app/GenieWidget.odex
rm /system/app/Gmail.apk
rm /system/app/Gmail.odex
rm /system/app/Gmail2.apk
rm /system/app/Gmail2.odex
rm /system/app/GmsCore.apk
rm /system/app/GmsCore.odex
rm /system/app/GoogleBackupTransport.apk
rm /system/app/GoogleBackupTransport.odex
rm /system/app/GoogleCalendar.apk
rm /system/app/GoogleCalendar.odex
rm /system/app/GoogleCalendarSyncAdapter.apk
rm /system/app/GoogleCalendarSyncAdapter.odex
rm /system/app/GoogleCamera.apk
rm /system/app/GoogleCamera.odex
rm /system/app/GoogleCloudPrint.apk
rm /system/app/GoogleCloudPrint.odex
rm /system/app/GoogleContactsSyncAdapter.apk
rm /system/app/GoogleContactsSyncAdapter.odex
rm /system/app/GoogleEars.apk
rm /system/app/GoogleEars.odex
rm /system/app/GoogleEarth.apk
rm /system/app/GoogleEarth.odex
rm /system/app/GoogleFeedback.apk
rm /system/app/GoogleFeedback.odex
rm /system/app/GoogleHangouts.apk
rm /system/app/GoogleHangouts.odex
rm /system/app/GoogleHindiIME.apk
rm /system/app/GoogleHindiIME.odex
rm /system/app/GoogleHome.apk
rm /system/app/GoogleHome.odex
rm /system/app/GoogleJapaneseInput.apk
rm /system/app/GoogleJapaneseInput.odex
rm /system/app/GoogleKeep.apk
rm /system/app/GoogleKeep.odex
rm /system/app/GoogleLatinIme.apk
rm /system/app/GoogleLatinIme.odex
rm /system/app/GoogleLoginService.apk
rm /system/app/GoogleLoginService.odex
rm /system/app/GoogleMusic.apk
rm /system/app/GoogleMusic.odex
rm /system/app/GoogleNow.apk
rm /system/app/GoogleNow.odex
rm /system/app/GoogleOneTimeInitializer.apk
rm /system/app/GoogleOneTimeInitializer.odex
rm /system/app/GooglePartnerSetup.apk
rm /system/app/GooglePartnerSetup.odex
rm /system/app/GooglePinyinIME.apk
rm /system/app/GooglePinyinIME.odex
rm /system/app/GooglePlay.apk
rm /system/app/GooglePlay.odex
rm /system/app/GooglePlus.apk
rm /system/app/GooglePlus.odex
rm /system/app/GoogleQuickSearchBox.apk
rm /system/app/GoogleQuickSearchBox.odex
rm /system/app/GoogleServicesFramework.apk
rm /system/app/GoogleServicesFramework.odex
rm /system/app/GoogleTTS.apk
rm /system/app/GoogleTTS.odex
rm /system/app/Hangouts.apk
rm /system/app/Hangouts.odex
rm /system/app/HangoutsDialer.apk
rm /system/app/HangoutsDialer.odex
rm /system/app/iWnnIME.apk
rm /system/app/iWnnIME.odex
rm /system/app/iWnnIME_Kbd_White.apk
rm /system/app/iWnnIME_Kbd_White.odex
rm /system/app/Keep.apk
rm /system/app/Keep.odex
rm /system/app/KoreanIME.apk
rm /system/app/KoreanIME.odex
rm /system/app/LatinIME.apk
rm /system/app/LatinIME.odex
rm /system/app/LatinImeDictionaryPack.apk
rm /system/app/LatinImeDictionaryPack.odex
rm /system/app/LatinImeGoogle.apk
rm /system/app/LatinImeGoogle.odex
rm /system/app/LatinImeTutorial.apk
rm /system/app/LatinImeTutorial.odex
rm /system/app/Magazines.apk
rm /system/app/Magazines.odex
rm /system/app/Maps.apk
rm /system/app/Maps.odex
rm /system/app/MarketUpdater.apk
rm /system/app/MarketUpdater.odex
rm /system/app/MediaUploader.apk
rm /system/app/MediaUploader.odex
rm /system/app/Music2.apk
rm /system/app/Music2.odex
rm /system/app/NetworkLocation.apk
rm /system/app/NetworkLocation.odex
rm /system/app/Newsstand.apk
rm /system/app/Newsstand.odex
rm /system/app/OccamQuickOffice.apk
rm /system/app/OccamQuickOffice.odex
rm /system/app/OneTimeInitializer.apk
rm /system/app/OneTimeInitializer.odex
rm /system/app/PartnerBookmarksProvider.apk
rm /system/app/PartnerBookmarksProvider.odex
rm /system/app/Phonesky.apk
rm /system/app/Phonesky.odex
rm /system/app/Photos.apk
rm /system/app/Photos.odex
rm /system/app/PlayAutoInstallConfig.apk
rm /system/app/PlayAutoInstallConfig.odex
rm /system/app/PlayGames.apk
rm /system/app/PlayGames.odex
rm /system/app/PlayStore.apk
rm /system/app/PlayStore.odex
rm /system/app/PlusOne.apk
rm /system/app/PlusOne.odex
rm /system/app/PrebuiltBugle.apk
rm /system/app/PrebuiltBugle.odex
rm /system/app/PrebuiltDeskClockGoogle.apk
rm /system/app/PrebuiltDeskClockGoogle.odex
rm /system/app/PrebuiltEmailGoogle.apk
rm /system/app/PrebuiltEmailGoogle.odex
rm /system/app/PrebuiltExchange3Google.apk
rm /system/app/PrebuiltExchange3Google.odex
rm /system/app/PrebuiltGmail.apk
rm /system/app/PrebuiltGmail.odex
rm /system/app/PrebuiltGmsCore.apk
rm /system/app/PrebuiltGmsCore.odex
rm /system/app/PrebuiltKeep.apk
rm /system/app/PrebuiltKeep.odex
rm /system/app/PrebuiltNewsWeather.apk
rm /system/app/PrebuiltNewsWeather.odex
rm /system/app/PrintSpooler.apk
rm /system/app/PrintSpooler.odex
rm /system/app/QuickOffice.apk
rm /system/app/QuickOffice.odex
rm /system/app/QuickSearchBox.apk
rm /system/app/QuickSearchBox.odex
rm /system/app/SetupWizard.apk
rm /system/app/SetupWizard.odex
rm /system/app/Street.apk
rm /system/app/Street.odex
rm /system/app/Talk.apk
rm /system/app/Talk.odex
rm /system/app/Tycho.apk
rm /system/app/Tycho.odex
rm /system/app/Velvet.apk
rm /system/app/Velvet.odex
rm /system/app/Vending.apk
rm /system/app/Vending.odex
rm /system/app/Videos.apk
rm /system/app/Videos.odex
rm /system/app/Wallet.apk
rm /system/app/Wallet.odex
rm /system/app/YouTube.apk
rm /system/app/YouTube.odex
rm /system/priv-app/AndroidForWork.apk
rm /system/priv-app/AndroidForWork.odex
rm /system/priv-app/BackupRestoreConfirmation.apk
rm /system/priv-app/BackupRestoreConfirmation.odex
rm /system/priv-app/Books.apk
rm /system/priv-app/Books.odex
rm /system/priv-app/Calendar.apk
rm /system/priv-app/Calendar.odex
rm /system/priv-app/CalendarGooglePrebuilt.apk
rm /system/priv-app/CalendarGooglePrebuilt.odex
rm /system/priv-app/CalendarProvider.apk
rm /system/priv-app/CalendarProvider.odex
rm /system/priv-app/Chrome.apk
rm /system/priv-app/Chrome.odex
rm /system/priv-app/CloudPrint2.apk
rm /system/priv-app/CloudPrint2.odex
rm /system/priv-app/ConfigUpdater.apk
rm /system/priv-app/ConfigUpdater.odex
rm /system/priv-app/ConnMO.apk
rm /system/priv-app/ConnMO.odex
rm /system/priv-app/DMAgent.apk
rm /system/priv-app/DMAgent.odex
rm /system/priv-app/Drive.apk
rm /system/priv-app/Drive.odex
rm /system/priv-app/EditorsDocs.apk
rm /system/priv-app/EditorsDocs.odex
rm /system/priv-app/EditorsSheets.apk
rm /system/priv-app/EditorsSheets.odex
rm /system/priv-app/EditorsSlides.apk
rm /system/priv-app/EditorsSlides.odex
rm /system/priv-app/FaceLock.apk
rm /system/priv-app/FaceLock.odex
rm /system/priv-app/FitnessPrebuilt.apk
rm /system/priv-app/FitnessPrebuilt.odex
rm /system/priv-app/GCS.apk
rm /system/priv-app/GCS.odex
rm /system/priv-app/GmsCore.apk
rm /system/priv-app/GmsCore.odex
rm /system/priv-app/GoogleBackupTransport.apk
rm /system/priv-app/GoogleBackupTransport.odex
rm /system/priv-app/GoogleCalendarSyncAdapter.apk
rm /system/priv-app/GoogleCalendarSyncAdapter.odex
rm /system/priv-app/GoogleCamera.apk
rm /system/priv-app/GoogleCamera.odex
rm /system/priv-app/GoogleContacts.apk
rm /system/priv-app/GoogleContacts.odex
rm /system/priv-app/GoogleContactsSyncAdapter.apk
rm /system/priv-app/GoogleContactsSyncAdapter.odex
rm /system/priv-app/GoogleDialer.apk
rm /system/priv-app/GoogleDialer.odex
rm /system/priv-app/GoogleEars.apk
rm /system/priv-app/GoogleEars.odex
rm /system/priv-app/GoogleEarth.apk
rm /system/priv-app/GoogleEarth.odex
rm /system/priv-app/GoogleFeedback.apk
rm /system/priv-app/GoogleFeedback.odex
rm /system/priv-app/GoogleHindiIME.apk
rm /system/priv-app/GoogleHindiIME.odex
rm /system/priv-app/GoogleHome.apk
rm /system/priv-app/GoogleHome.odex
rm /system/priv-app/GoogleJapaneseInput.apk
rm /system/priv-app/GoogleJapaneseInput.odex
rm /system/priv-app/GoogleLoginService.apk
rm /system/priv-app/GoogleLoginService.odex
rm /system/priv-app/GoogleNow.apk
rm /system/priv-app/GoogleNow.odex
rm /system/priv-app/GoogleOneTimeInitializer.apk
rm /system/priv-app/GoogleOneTimeInitializer.odex
rm /system/priv-app/GooglePackageInstaller.apk
rm /system/priv-app/GooglePackageInstaller.odex
rm /system/priv-app/GooglePartnerSetup.apk
rm /system/priv-app/GooglePartnerSetup.odex
rm /system/priv-app/GooglePinyinIME.apk
rm /system/priv-app/GooglePinyinIME.odex
rm /system/priv-app/GoogleServicesFramework.apk
rm /system/priv-app/GoogleServicesFramework.odex
rm /system/priv-app/Hangouts.apk
rm /system/priv-app/Hangouts.odex
rm /system/priv-app/HotwordEnrollment.apk
rm /system/priv-app/HotwordEnrollment.odex
rm /system/priv-app/KoreanIME.apk
rm /system/priv-app/KoreanIME.odex
rm /system/priv-app/LatinImeGoogle.apk
rm /system/priv-app/LatinImeGoogle.odex
rm /system/priv-app/Maps.apk
rm /system/priv-app/Maps.odex
rm /system/priv-app/Music2.apk
rm /system/priv-app/Music2.odex
rm /system/priv-app/Newsstand.apk
rm /system/priv-app/Newsstand.odex
rm /system/priv-app/OneTimeInitializer.apk
rm /system/priv-app/OneTimeInitializer.odex
rm /system/priv-app/Phonesky.apk
rm /system/priv-app/Phonesky.odex
rm /system/priv-app/Photos.apk
rm /system/priv-app/Photos.odex
rm /system/priv-app/PlayAutoInstallConfig.apk
rm /system/priv-app/PlayAutoInstallConfig.odex
rm /system/priv-app/PlayGames.apk
rm /system/priv-app/PlayGames.odex
rm /system/priv-app/PlusOne.apk
rm /system/priv-app/PlusOne.odex
rm /system/priv-app/PrebuiltBugle.apk
rm /system/priv-app/PrebuiltBugle.odex
rm /system/priv-app/PrebuiltEmailGoogle.apk
rm /system/priv-app/PrebuiltEmailGoogle.odex
rm /system/priv-app/PrebuiltExchange3Google.apk
rm /system/priv-app/PrebuiltExchange3Google.odex
rm /system/priv-app/PrebuiltGmail.apk
rm /system/priv-app/PrebuiltGmail.odex
rm /system/priv-app/PrebuiltGmsCore.apk
rm /system/priv-app/PrebuiltGmsCore.odex
rm /system/priv-app/PrebuiltKeep.apk
rm /system/priv-app/PrebuiltKeep.odex
rm /system/priv-app/PrebuiltNewsWeather.apk
rm /system/priv-app/PrebuiltNewsWeather.odex
rm /system/priv-app/QuickSearchBox.apk
rm /system/priv-app/QuickSearchBox.odex
rm /system/priv-app/SetupWizard.apk
rm /system/priv-app/SetupWizard.odex
rm /system/priv-app/Street.apk
rm /system/priv-app/Street.odex
rm /system/priv-app/TagGoogle.apk
rm /system/priv-app/TagGoogle.odex
rm /system/priv-app/Talkback.apk
rm /system/priv-app/Talkback.odex
rm /system/priv-app/Velvet.apk
rm /system/priv-app/Velvet.odex
rm /system/priv-app/Vending.apk
rm /system/priv-app/Vending.odex
rm /system/priv-app/Videos.apk
rm /system/priv-app/Videos.odex
rm /system/priv-app/Wallet.apk
rm /system/priv-app/Wallet.odex
rm /system/priv-app/YouTube.apk
rm /system/priv-app/YouTube.odex
rm /system/vendor/lib/libfrsdk.so