title: Why APK could not be installed after Smali patching?
body: <p>Here is the <strong>TestClass</strong> and <strong>MainActivity</strong>.</p>
  <p><a href="https://i.stack.imgur.com/Vfb5X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vfb5X.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/rwmKp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rwmKp.png" alt="enter image description here" /></a></p>
  <p>In order to always show the <strong>Toast</strong>, I changed <strong>TestClass</strong> <strong>constructor</strong> <em>using smali patching</em> to following:</p>
  <p><a href="https://i.stack.imgur.com/z4zN0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z4zN0.png" alt="enter image description here" /></a></p>
  <p>but after compiling and signing, the new patched apk could not be installed.</p>
  <p>where is the problem??</p>
  <p>Here is the patching code:</p>
  <pre><code>iput-boolean p1, p0, Lcom/example/test1/TestClass;-&gt;testB:Z
  
  if-nez p1, :cond_0
  
  const/4 p1, 0x1
  
  iput-boolean p1, p0, Lcom/example/test1/TestClass;-&gt;testB:Z
  
  :cond_0
  </code></pre>
  <p>This is the LOGCAT during installation:</p>
  <pre><code>1772  1772 D AndroidRuntime: &gt;&gt;&gt;&gt;&gt;&gt; START com.android.internal.os.RuntimeInit uid 0 &lt;&lt;&lt;&lt;&lt;&lt;
  
  1772  1772 D AndroidRuntime: CheckJNI is OFF
  
  1772  1772 D ICU     : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
  
  1772  1772 E memtrack: Couldn't load memtrack module (No such file or directory)
  
  1772  1772 E android.os.Debug: failed to load memtrack module: -2
  
  1772  1772 I Radio-JNI: register_android_hardware_Radio DONE
  
  1772  1772 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
  
  1594  1606 D DefContainer: Copying /data/local/tmp/app-release_SIGNED_UNALIGNED.apk to base.apk
  
   637   662 D NativeLibraryHelper: Library 'libtoolChecker.so' is not page-aligned - will not be able to open it directly from apk.
  
   637   662 W NativeHelper: Failure copying native libraries [errorCode=-2]
  
   637   662 I art     : Starting a blocking GC Explicit
  
   637   662 I art     : Explicit concurrent mark sweep GC freed 34438(1881KB) AllocSpace objects, 2(40KB) LOS objects, 33% free, 6MB/9MB, paused 267us total 14.270ms
  
  1772  1772 I art     : System.exit called, status: 1
  
  1772  1772 I AndroidRuntime: VM exiting with result code 1.
  </code></pre>