Unable to install a modified apk file I want to monitor the https traffic of an Android app downloaded from google play.
This app can only be run at Android N and above.
So I use Charles proxy and follow this document to modify the apk file.
Here's what I have done:

Download the app from google play.

Use apk extractor to get the apk file of the app.

Run apktool d the_app.apk to extract the apk file.

Modify res/xml/network_security_config.xml and AndroidManifest.xml based on the description of Charles Proxy document.

Run apktool b the_app to package the files back to an apk file.

Install the apk on my Android phone, whose version is 8.

My phone says &quot;App not installed&quot;.


Why can't I install the modified apk on my phone?
I've disabled Google Play Protect on my phone.
The apktool is installed by following the description here.
Is there anything I missed?
The generated APK file by apktool needs to be signed before you can install it on a Android phone or emulator:
First you have to create a key-pair for signing stored in a keystore (only required once):
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Note this command uses keytool for JDK. source
Then you have to sign the app using apksigner which is part of the Android SDK:
java -jar build-tools\29.0.3\lib\apksigner.jar sign -ks my-release-key.keystore &lt;apkfile&gt;

Now you can install it on the device:
adb install &lt;apkfile&gt;

If you have the original apk file installed on device you have to uninstall it. because of the changed signature you can install your modified apk file over the already installed original file.