I'm doing a basic project in Android Studio in its latest version that I downloaded in May 2018, when I try to compile the project I get the classic error of "AAPT2 error: check logs for details" which the whole Main class me marks errors in the letters R.layout. Now looking in other forums I found that to avoid this error we have to return to an older version of drivers with the instruction android.enableAapt2 = false in gradle.properties and giving it in Sync Now to compile it which I already tried thinking that my problem would be solved and throws me the following:
The option 'android.enableAapt2' is deprecated and should not be used anymore. Use 'android.enableAapt2 = true' to remove this warning. It will be removed at the end of 2018 ..
I need help please because this is what I do for every project I create.
This is the Main class: package com.example.obed.calculadorasuri;
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
EditText num1, num2;
Button suma , resta , mult, divi;
TextView resultado;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
num1 = (EditText) findViewById(R.id.num1);
num2 = (EditText) findViewById(R.id.num2);
suma = (Button) findViewById(R.id.sumar);
resta = (Button) findViewById(R.id.restar);
mult = (Button) findViewById(R.id.multiplicar);
divi = (Button) findViewById(R.id.dividir);
resultado = (TextView) findViewById(R.id.resultado);
suma.setOnClickListener(this);
resta.setOnClickListener(this);
mult.setOnClickListener(this);
divi.setOnClickListener(this);
}
@Override
public void onClick(View v) {
String n1 = num1.getText().toString();
String n2 = num2.getText().toString();
int entero1=Integer.parseInt(n1);
int entero2=Integer.parseInt(n2);
int rta=0;
switch(v.getId()){
case R.id.sumar:
rta=entero1+entero2;
break;
case R.id.restar:
rta=entero1-entero2;
break;
case R.id.multiplicar:
rta=entero1*entero2;
break;
case R.id.dividir:
rta=entero1/entero2;
break;
}
resultado.setText(""+rta);
}
}