title: Apktool - app instantly crashes after repackaging
body: <p>In this instance I used this app:
  <a href="https://apkpure.com/perfect-piano/com.gamestar.perfectpiano/download/2100713-APK?from=details%2Fversion" rel="nofollow noreferrer">Perfect_Piano_v7.1.3_apkpure.com</a></p>
  <p>Apktool version: v2.3.3 IBotPeaches fork <a href="https://github.com/iBotPeaches/Apktool/releases/tag/v2.3.3" rel="nofollow noreferrer">https://github.com/iBotPeaches/Apktool/releases/tag/v2.3.3</a></p>
  <p>The original app works fine on my device and emulator, but after I unpack and repack it with and reinstall it, the app crashes instantly. I made no changes to the app before rebuilding, and use <code>--no-src</code> flag to not decompile <code>smali</code> files.</p>
  <pre><code>apktool d -f --no-src Perfect_Piano_v7.1.3_apkpure.com.apk
  rm Perfect_Piano_v7.1.3_apkpure.com.apk
  apktool b -f Perfect_Piano_v7.1.3_apkpure.com
  jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore Perfect_Piano_v7.1.3_apkpure.com.apk alias_name
  </code></pre>
  <p>I also tried building with <code>--use-aapt2</code> flag.</p>
  <p>Logcat throws the following error:</p>
  <pre><code>05-30 19:59:13.781 1691-1714/? W/WindowManager: Failed looking up window
                                                  java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@29a1c85 does not exist
                                                      at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8733)
                                                      at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8724)
                                                      at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2697)
                                                      at com.android.server.wm.Session.remove(Session.java:187)
                                                      at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:3099)
                                                      at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5606)
                                                      at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3409)
                                                      at android.os.Handler.dispatchMessage(Handler.java:102)
                                                      at android.os.Looper.loop(Looper.java:148)
                                                      at android.os.HandlerThread.run(HandlerThread.java:61)
                                                      at com.android.server.ServiceThread.run(ServiceThread.java:46)
  </code></pre>
  <p>You may find full logcat log in this <a href="https://pastebin.com/aE5tjnuU" rel="nofollow noreferrer">pastebin</a></p>
  <h2>Hypothesis</h2>
  <ul>
  <li>Since I don't actually decode <code>.dex</code> files, hence <code>--no-src</code> flag, the problem is probably have nothing to do with <code>smali</code> compiling.</li>
  <li>Could it be some kind of anti-tamper protection?</li>
  <li>The result file is smaller than original (original 16.67 Mb result 13.96 Mb), all resources are exactly the same, but when viewed in the archive they are more compressed, so maybe issues with resource compression?</li>
  </ul>
  <p>I'm clueless at this point, I'm experiencing the same issues with some other <code>.apk</code> files as well.</p>
  <p><a href="https://github.com/iBotPeaches/Apktool/issues/1806" rel="nofollow noreferrer">I submitted this issue in github.</a></p>