0
Good afternoon, I have an error in Android Studio and I can’t fix it.
When I opened my project several messages like cannot resolve the symbol
and in red they appeared, as it is in the image.
Can someone help me, please? Like my Mainactivity.
public class MainActivity extends AppCompatActivity {
private static final String BASE_URL = "http://192.168.1.8:8080/gms/webresources/usuario/";
private static final Gson g = new GsonBuilder().registerTypeAdapter(usuario.class, new dec()).create();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*List<usuario.usuarioData> list = bd.buscar();
for(int i = 0; i < list.size(); i++){
System.out.println("AQUI" + list.get(i));
}*/
}
public void entrarSistema(View view) {
final db_funcao bd = new db_funcao(this);
usuarioDAO dao = new usuarioDAO();
final EditText login = (EditText) findViewById(R.id.usuario);
EditText senha = (EditText) findViewById(R.id.senha);
//VERIFICA SE OS EDITTEXT SÃO VAZIOS
if (login.getText().length() == 0) {
login.setError("Campo vazio");
} else {
if (senha.getText().length() == 0) {
senha.setError("Campo vazio");
} else {
if (senha.getText().length() < 6) {
senha.setError("Senha incorreta");
} else {
Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create(g)).build();
usuarioService service = retrofit.create(usuarioService.class);
Call<String> user = service.verificarUsuario(login.getText().toString(), senha.getText().toString());
user.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
String resultado = response.body();
if (resultado.equals("false")) {
Toast toast = Toast.makeText(MainActivity.this, "Senha ou usuário não existente", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP | Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
} else { //TOAST LOGIN
if (resultado.equals("true")) {
Toast toast = Toast.makeText(MainActivity.this, "ACESSO PERMITIDO", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create(g)).build();
usuarioService service = retrofit.create(usuarioService.class);
retrofit2.Call<List<String>> dados = service.verificarCargoENome(login.getText().toString());
dados.enqueue(new Callback<List<String>>() {
@Override
public void onResponse
(retrofit2.Call <List<String>> call, Response <List<String>>response)
{
if (response.isSuccessful()) {
List<usuarios> dados = response.body();
for (usuarios u : users) {
Log.i("USER", u.getNome());
Log.i("USER", "----------------------------------------------------------");
}
} else {
Log.i("USER", String.valueOf(response.code()));
Log.i("USER", "----------------------------------------------------------");
}
}
@Override
public void onFailure
(retrofit2.Call < List < usuarios >> call, Throwable t){
Log.i("USER", t.getMessage());
Log.i("USER", "----------------------------------------------------------");
}
});
String nome = bd.verificarUsuario(login.getText().toString());
String cargo = bd.verificarCargo(login.getText().toString());
Intent intent = new Intent(MainActivity.this, MenuDrawer.class);
intent.putExtra("chave1", nome);
intent.putExtra("chave2", cargo);
startActivity(intent);
finish();
}
}
}
@Override
public void onFailure(Call<String> call, Throwable t) {
}
});
}
}
}
}
//CHAMA UMA ACTIVITY (TELA)
void recuperarSenha(View view) {
Intent intent = new Intent(this, recuperarSenha.class);
startActivity(intent);
}
}
@My code is all like this. The purpose of the question is not directly linked to the code. Or implementation forms. When I opened my Androidstudio all the project code was as explained in the question and in Red. I entered the Code too, even though it doesn’t make sense because it’s not the best way to visualize the problem.
– Lucas Charles
I understand, the problem would be similar to this? https://answall.com/q/70925/28595
– user28595
@Articuno would be no. It was normal until I restarted the pc and stay like this.
– Lucas Charles
But the error is just that? So I searched, usually there is something else in the message, as in the link:
cannot resolve the symbol R
. The message doesn’t say which symbol you can’t solve?– user28595
@Yes article. Each "mark" in red as shown in the image, appears :
cannot resolve the ...
– Lucas Charles