Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Meu list_view não está sendo reconhecido

O Erro que está aparecendo pe de compilação

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  Output:  C:\Users\User\Documents\GitHub\Agenda\app\src\main\res\layout\list_item.xml:2: error: XML or text declaration not at start of entity.

  Command: C:\Users\User\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\fc444429c9ac9f1db8d9bb3790bf9413\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
          -o \
          C:\Users\User\Documents\GitHub\Agenda\app\build\intermediates\res\merged\debug \
          C:\Users\User\Documents\GitHub\Agenda\app\src\main\res\layout\list_item.xml
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
11 actionable tasks: 3 executed, 8 up-to-date
Exception in thread "ForkJoinPool.commonPool-worker-0" java.lang.IllegalStateException: AAPT Process manager cannot be shut down while daemons are in use
    at com.android.builder.internal.aapt.v2.Aapt2DaemonManager.shutdown(Aapt2DaemonManager.kt:96)
    at com.android.build.gradle.internal.res.namespaced.RegisteredAaptService.shutdown(Aapt2DaemonManagerService.kt:61)
    at com.android.build.gradle.internal.workeractions.WorkerActionServiceRegistry$shutdownAllRegisteredServices$1$1.run(WorkerActionServiceRegistry.kt:96)
    at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
3 respostas

Minha Classe adapter igual da aula atual

package br.com.teste.agenda.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import br.com.teste.agenda.ListaAlunosActivity;
import br.com.teste.agenda.modelo.Aluno;

public class AlunosAdapter extends BaseAdapter {
    private final List<Aluno> alunos;
    private final Context context;

    public AlunosAdapter(Context context, List<Aluno> alunos) {
        this.context = context;
        this.alunos = alunos;
    }

    @Override
    public int getCount() {
        return alunos.size();
    }

    @Override
    public Object getItem(int position) {
        return alunos.get(position);
    }

    @Override
    public long getItemId(int position) {
        return alunos.get(position).getId();
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        TextView view = new TextView(context);
        Aluno aluno = alunos.get(position);
        view.setText(aluno.toString());
        return view;
    }
}

Meu metodo carrega lista

private void carregaLista() {
        AlunoDAO dao = new AlunoDAO(this);
        List<Aluno> alunos = dao.buscaAlunos();
        dao.close();

   AlunosAdapter adapter = new AlunosAdapter(this,alunos);
        listaAlunos.setAdapter(adapter);
    }

Era para aparecer a tela dos alunos certo, está idêntico até a aula atual, o que pode estar errado?

solução!

Pessoal já descobri o problema, essa declaração estava duplicada

<?xml version="1.0" encoding="utf-8"?>

E tinha um erro no nome da variavel que estava duplicada!

Resolvido!