Socket communication error

1

I have this code snippet:

public class Consulta extends AsyncTask<Void, Void, Void> {

    @Override
    protected Void doInBackground(Void... params) {
        try {
            Socket cliente = new Socket("10.20.1.100", 12345);
            ObjectInputStream entrada = new ObjectInputStream(cliente.getInputStream());
            List<PessoaMOD> pessoas = (List) entrada.readObject();
            for (PessoaMOD p : pessoas) {
                Log.d("teste", "ID: " + p.getId() + " - Nome: " + p.getNome());
            }
            entrada.close();
            Log.d("teste", "Conexão encerrada");
        } catch (Exception e) {
            Log.d("teste", "Erro: " + e);
        }

        return null;
    }
}

private void botaoComunicarServidor() {
    Button btComunicarServidor = (Button) findViewById(R.id.btComunicarServidor);
    btComunicarServidor.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            new Consulta().execute();
        }
    });
}

public class PessoaMOD implements Serializable{
    private int id;
    private String nome;

    public PessoaMOD(int id, String nome){
        setId(id);
        setNome(nome);
    }

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getNome() {
        return nome;
    }
    public void setNome(String nome) {
        this.nome = nome;
    }
}

It gives the following error: java.lang.ClassNotFoundException: PessoaMOD

In a java application, this same code I use on Android works ...

In MANIFEST I have already released access to the Internet:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

----------------- EDIT ------------------

I discovered the error, but I do not know how to solve it ... haha

The error occurs because the package name of the PersonMOD class on the server is different from the package name of the client application. I put the same package name and it worked. But I changed the name just to test, I can not change the package name ... How can I solve this?

    
asked by anonymous 22.02.2016 / 15:00

0 answers