Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferences in an exported, signed apk and version running in Eclipse debugger? Serializeable class causing problems
    primarykey
    data
    text
    <p>Hopefully this won't be too long-winded, but trying to be complete:</p> <p>So I have an app on the Android Market. Within the app are a few Serializable classes. App is working fine everywhere (in emulator, on debugging phone, on phones that download the app).</p> <p>I made a decision to add some features. Those features involve implementing Comparable on one of my Serializable classes. In Eclipse (emulator or attached phone), the changes seem valid. Also according to <a href="http://download.oracle.com/javase/6/docs/platform/serialization/spec/version.html#6678" rel="nofollow">this Java document</a>, I think the changes are valid changes to a Serializable class.</p> <p>Now to the problem. It seems that after exporting a signed apk, I have crashes in the app. The crashes occur the first time the altered class is touched. The stack trace is obfuscated, and the details aren't too important (I think), but it is a NullPointerException crashing the app.</p> <p>Here is the changed code from my experiments:</p> <p><strong>The Comparable version:</strong></p> <pre><code>public class Card implements Serializable, Comparable&lt;Card&gt;{ </code></pre> <p>with the added method:</p> <pre><code>public int compareTo(Card another) { if( another.getName() == null ) return -1; if( this.getName() == null ) return 1; return this.getName().compareTo(another.getName()); } </code></pre> <p><strong>The Regular/Original Version:</strong></p> <pre><code>public class Card implements Serializable/*, Comparable&lt;Card&gt;*/{ </code></pre> <p>without the added method. </p> <p>The classes are identical otherwise. Note that getName() returns a String.</p> <p>I performed the following experiment:</p> <ol> <li>Uninstall the app completely from my phone.</li> <li>Build the app without the Comparable change to the code and run on my phone through Eclipse. (runs fine).</li> <li>Implement the Comparable change and run on my phone through Eclipse. (runs fine).</li> </ol> <p>No problems here. Now I exported a signed version of the each build described above.</p> <ol> <li>Uninstall the app completely from my phone.</li> <li>Export signed version of app without Comparable change. Upload to phone using: adb install com.myapp (runs fine).</li> <li>Export signed version of app WITH Comparable change. Upload using adb. Crash upon accessing previously saved (NullPointerException).</li> </ol> <p>And as a sanity check I did the following:</p> <ol> <li>Uninstall the app completely from phone.</li> <li>install the exported, signed version of the app WITH Comparable change. No problems.</li> </ol> <p>Note that the reason for NOT uninstalling in between steps 1. and 2. is to simulate the end user preserving his/her data between updates (an important feature here). Also note that the final sanity check above leads me to feel fairly certain it is an issue with the change to the Serializeable class.</p> <p>So the fundamental questions are: What are the differences between a signed, exported app versus a version run from within Eclipse? Is there a reason that a valid change to a Serializable class would break the app after export?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload