- 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.
I just re-tested the instructions with the APK downloaded from here:
https://www.apkmirror.com/apk/microsoft-corporation/microsoft-teams/microsoft-teams-1416-1-0-0-2022394701-release/microsoft-teams-1416-1-0-0-2022394701-android-apk-download/
and don't get any crash after entering my email address. Can you check Android logs (e.g.,
adb logcat "*:E") to see why it's crashing?With the newest Teams version, I was able to reproduce the crash right after starting the app. The log in this case is:
That seems to be related to this bug in apktool: iBotPeaches/Apktool#3616. A workaround might be to remove all references to OpenTelemetry, but that would take some time...