RuntimeException: Parseable encountered IOException reading a Serializable object

2

I can not understand let alone run my app .. Can someone give me a light?

@Override
            public void onClick(View arg0) {
                try{
                    Intent i = new Intent(Activity_Questionario.this, Activity_Conf_Inicio_Ques.class);


                    PerguntaAdapter adapter = (PerguntaAdapter) lv.getAdapter();
                    List < Pergunta > ListaPergunta = adapter.getPerguntas();

                    final ArrayList < SerializablePair< Integer, Boolean > > respostas = new ArrayList < SerializablePair< Integer, Boolean > > (ListaPergunta.size());

                    for (Pergunta pergunta: ListaPergunta) {
                        respostas.add(new SerializablePair< Integer, Boolean >(pergunta.getId(), pergunta.getResposta()));
                    }

                    Log.i("Verificação", "Verificando: " + respostas);
                    //Log.i("Senha no Click", "Senha: " + senha);

                    i.putExtra("respostas", respostas);

                    startActivity(i);

                }catch(Exception erro){
                    erro.printStackTrace();
                }
            }
        });

And the other class that receives the values ... I believe the error is giving this line of ArrayList

try{
            ArrayList<SerializablePair<Integer, Boolean>> respostas = (ArrayList<SerializablePair<Integer, Boolean>>) getIntent().getSerializableExtra("respostas");
            Log.i("Respostas na Confirmação", "Respostas: "+respostas);

            String urlPost = "http://"+l.IP+"/projetotcc/android/respostas.php";
            ArrayList<NameValuePair> parametrosPost = new ArrayList<NameValuePair>();

            for(SerializablePair<Integer, Boolean> item : respostas){

                Log.i("Entrou", "Entrou no for(SerializablePair<Integer, Boolean> item : a)");
                parametrosPost.add(new BasicNameValuePair("codigoQuestionario", item.first.toString()));
                parametrosPost.add(new BasicNameValuePair("codigoPaciente", item.second.toString()));

            }

        }catch(Exception erro){
            erro.printStackTrace();
            Toast.makeText(this, "Erro: "+erro, Toast.LENGTH_LONG).show();

        }

LogCat:

  

10-17 14: 12: 39,090: W / System.err (2785): java.lang.RuntimeException:   Parameterable encountered IOException reading a Serializable object (name   10-17 14: 12: 39,100: W / System.err (2785): at   android.os.Parcel.readSerializable (Parcel.java:2144) 10-17   14: 12: 39,100: W / System.err (2785): at   android.os.Parcel.readValue (Parcel.java:2016) 10-17 14: 12: 39,110:   W / System.err (2785): at   android.os.Parcel.readListInternal (Parcel.java:2235) 10-17   14: 12: 39,110: W / System.err (2785): at   android.os.Parcel.readArrayList (Parcel.java:1655) 10-17 14: 12: 39,120:   W / System.err (2785): at android.os.Parcel.readValue (Parcel.java:1986)   10-17 14: 12: 39,130: W / System.err (2785): at   android.os.Parcel.readMapInternal (Parcel.java:2226) 10-17   14: 12: 39,130: W / System.err (2785): at   android.os.Bundle.unparcel (Bundle.java:223) 10-17 14: 12: 39,150:   W / System.err (2785): at   android.os.Bundle.getSerializable (Bundle.java:1254) 10-17   14: 12: 39,150: W / System.err (2785): at   android.content.Intent.getSerializableExtra (Intent.java:4182) 10-17   14: 12: 39,150: W / System.err (2785): at   br.projetotcc.visao.Activity_Conf_Inicio_Ques.onCreate (Activity_Conf_Inicio_Ques.java:45)   10-17 14: 12: 39,162: W / System.err (2785): at   android.app.Activity.performCreate (Activity.java:5008) 10-17   14: 12: 39,162: W / System.err (2785): at   android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1079)   10-17 14: 12: 39,180: W / System.err (2785): at   android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2023)   10-17 14: 12: 39,180: W / System.err (2785): at   android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2084)   10-17 14: 12: 39,180: W / System.err (2785): at   android.app.ActivityThread.access $ 600 (ActivityThread.java:130) 10-17   14: 12: 39.190: W / System.err (2785): at   android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1195)   10-17 14: 12: 39: 00: W / System.err (2785): at   android.os.Handler.dispatchMessage (Handler.java:99) 10-17   14: 12: 39,200: W / System.err (2785): at   android.os.Looper.loop (Looper.java:137) 10-17 14: 12: 39.210:   W / System.err (2785): at   android.app.ActivityThread.main (ActivityThread.java:4745) 10-17   14: 12: 39,220: W / System.err (2785): at   java.lang.reflect.Method.invokeNative (Native Method) 10-17   14: 12: 39,240: W / System.err (2785): at   java.lang.reflect.Method.invoke (Method.java:511) 10-17 14: 12: 39,240:   W / System.err (2785): at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:786)   10-17 14: 12: 39,251: W / System.err (2785): at   com.android.internal.os.ZygoteInit.main (ZygoteInit.java:553) 10-17   14: 12: 39,260: W / System.err (2785): at   dalvik.system.NativeStart.main (Native Method) 10-17 14: 12: 39,280:   W / System.err (2785): Caused by: java.io.InvalidClassException:   android.util.Pair; IllegalAccessException 10-17 14: 12: 39,300:   W / System.err (2785): at   java.io.ObjectStreamClass.resolveConstructorClass (ObjectStreamClass.java:694)   10-17 14: 12: 39,310: W / System.err (2785): at   java.io.ObjectStreamClass.newInstance (ObjectStreamClass.java:655)   10-17 14: 12: 39,310: W / System.err (2785): at   java.io.ObjectInputStream.readNewObject (ObjectInputStream.java:1816)   10-17 14: 12: 39,310: W / System.err (2785): at   java.io.ObjectInputStream.readNonPrimitiveContent (ObjectInputStream.java:787)   10-17 14: 12: 39,329: W / System.err (2785): at   java.io.ObjectInputStream.readObject (ObjectInputStream.java:2003)   10-17 14: 12: 39,329: W / System.err (2785): at   java.io.ObjectInputStream.readObject (ObjectInputStream.java:1960)   10-17 14: 12: 39,341: W / System.err (2785): at   android.os.Parcel.readSerializable (Parcel.java:2142) 10-17   14: 12: 39,350: W / System.err (2785): ... 23 more

SerializablePair class

import java.io.Serializable; import android.util.Pair;

public class SerializablePair extends Pair implements Serializable {

public SerializablePair(F first, S second) {
    super(first, second);
    // TODO Auto-generated constructor stub
}

}

    
asked by anonymous 17.10.2014 / 16:20

1 answer

4

Note: On Android, it is usually more convenient to start the analysis of stack trace from the end by going through the problems until we find the last reference to "Caused By". This last reference usually points to the specific problem we are facing.

You do not have all LogCat output, but the cause of your problem seems to be:

java.io.InvalidClassException: android.util.Pair; IllegalAccessException

In short, you are trying to access a field or method that is not accessible during serialization or deserialization.

Decomposing the problem a little:

IllegalAccessException

  

Thrown when a program attempts to access a field or method which is not accessible from the location where the reference is made.

What translated:

  

Launched when a program attempts to access a field or method that is not accessible from the location where the reference is made.

android.util.Pair

  

Container to ease passing around a tuple of two objects. This object provides a sensible implementation of equals (), returning true if equals () is true on each of the contained objects.

What translated:

  

Container to facilitate the passage around a tuple of two objects. This object provides a sensible implementation of equals (), returning true if equals () is true on each of the contained objects.

java.io.InvalidClassException

  

Signals a problem during the serialization or deserialization of an object.

What translated:

  

Signals a problem during serialization or deserialization of an object.

    
17.10.2014 / 17:07