You are discouraged to use Java serialization on the Android platform for performance reasons. Instead, Android comes with its own serialization tool: Parcelable. A Parcelable class requires you to implement the Parcelable interface and also to fulfill a certain contract as shown below:

import android.os.Parcel;
import android.os.Parcelable;

public class User implements Parcelable {
    private int age;

    private String name;

    // Getters and Setters [...]

    public User(int age, String name) {
        this.age = age; = name;

    protected User(Parcel source) {
        this(source.readInt(), source.readString())

    public int describeContents() { return 0; }

    public void writeToParcel(Parcel destination, int flags) {

    // Implemented by contract, if this field is not around you will encounter runtime exceptions
    public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
        public User createFromParcel(Parcel source) { return new User(source); }

        public User[] newArray(int size) { return new User[size]; }

A Parcelable class forces you to implement a lot of boilerplate code, but offers great performance as it does not rely on runtime reflection like the default Java serialization framework. When it comes to Scala on Android there emerges another problem: the Parcelable contract requires a static class field. At first glance this seems to be an issue in Scala as there is no support for static members.

Luckily, the Scala compiler checks for Android’s Parcelable interface and treats it in a special way to support Android development. At the end of the day there is just another contract to implement that relies on the class’ companion to overcome the lack of statics. Below is a valid Scala implementation of the previous example.

import android.os.{ Parcel, Parcelable }

case class User( age: Int, name: String ) extends Parcelable {
  protected this(source: Parcel) = this(source.readInt(), source.readString())

  override def describeContents() = 0

  override def writeToParcel(destination: Parcel, flags: Int) {

object User {
  // This is by contract:
  // the CREATOR field must exist for every class that implements the Parcelable interface.
  override val CREATOR = new Parcelable.Creator[User] {
    override def createFromParcel(source: Parcel) = new User(source)
    override def newArray(size: Int) = new Array[User](size)