AAPT2 error: check logs for details in Android Studio

1

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. Item   will be removed at the end of 2018 ..

I need help please because this is what I do for every project I create.

package com.example.obed.mycalculadorafinal;

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);
    }
}

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
    android:ide="@+id/num1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:imputType="number"
    android:hint="número 1"
    />
<EditText
    android:ide="@+id/num2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:imputType="number"
    android:hint="número 2"
    />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <Button
        android:id="@+id/sumar"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:text="Sumar"
        android:textSize="15sp"
        />
    <Button
        android:id="@+id/restar"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:text="Restar"
        android:textSize="15sp"
        />
    <Button
        android:id="@+id/multiplicar"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:text="Multi"
        android:textSize="15sp"
        />
    <Button
        android:id="@+id/dividir"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:text="Dividir"
        android:textSize="15sp"
        />

</LinearLayout>
<TextView
    android:id="@+id/resultado"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="00"
    android:gravity="center"
    android:textSize="120sp"/>

    
asked by Suri Gang's Hallen 23.05.2018 в 06:41
source

1 answer

-1

You can actually have problems in the resources but these will not be displayed if you do not correct the error first:

  

The option 'android.enableAapt2' is deprecated and should not be used   anymore Use 'android.enableAapt2 = true' to remove this warning. Item   will be removed at the end of 2018.

for this, within your file gradle.properties that is in the root of the project replaces:

android.enableAapt2

by:

android.enableAapt2=true
    
answered by 23.05.2018 в 16:21