- apktool
zipalignandapksignerand from the Android SDK Build Toolskeytoolfrom a Java JRE or JDK
-
Get the APK of the current MS Teams app (e.g. by copying it from your phone or downloading from APKMirror). These instructions were tested with version
1416/1.0.0.2022394701, and assume it is saved asteams.apk. -
Extract the APK:
apktool -r d teams.apk -
Find the
WebViewAuthorizationFragmentclass. In the current version it is undersmali_classes3/com/microsoft/identity/common/internal/providers/oauth2/WebViewAuthorizationFragment.smali. -
In this class, in the
setUpWebViewfunction, the User-Agent for the WebView is set like this:invoke-virtual {v0, p1}, Landroid/webkit/WebSettings;->setUserAgentString(Ljava/lang/String;)VRight before this, add the following line to override the User-Agent:
const-string p1, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"(or another recent desktop User-Agent)
-
In theThis seems to be no longer necessary in the newest version of the Teams app. Yay! 🥳res/rawdirectory, in each of the filesmsal_config.json,msal_config_opt_disabled.json,msal_enterprise_config.jsonandmsal_enterprise_config_opt_disabled.json, set thebroker_redirect_uri_registeredsetting tofalse. This is needed because the modified APK will be signed with a different key. -
Rebuild the APK:
apktool b teams -o teams_mod.apkIf you need to install the app alongside the official Teams app, change the package name now and rename conflicting content providers in the Manifest (e.g. using this tool):
git clone git@github.com:johan12345/ApkRename.git ApkRename/apkRename.sh teams_mod.apk com.microsoft.teams.mod! -
Zipalign:
zipalign -f -p 4 teams_mod.apk teams_mod_zipalign.apk -
Sign the APK:
keytool -genkey -keystore keys.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias Teams apksigner sign --ks keys.keystore --out teams_mod_signed.apk teams_mod_zipalign.apk -
Install the resulting
teams_mod_signed.apkon your Android device. If you did not change the package name above, you will need to uninstall the official version of Teams first due to the different signature.
Well, that is not a crash, just an error message from Microsoft - so likely your company's MS sign-in page does not like the modified Teams app. In my company's case, it would directly redirect to the company's own sign-in page after entering the email address (and that just identifies mobile devices based on their User-Agent), so maybe that is why I haven't encountered this? 🤔