Error while completing app created in Android Studio

1

When you enter a ImageView , and try to run the app on the emulator, it displays the following message on the screen: **com.android.phone has stopped** , plus this message disappears and it executes normally.

But when I run on the phone, it has the following error:

  

Caused by: android.content.res.Resources $ NotFoundException: Resource ID # 0x7f060056

Soon after that, close the application.

*************************** XML ******************* ***************************

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="24dp"
    android:text="Aposte na sua sorte!"
    android:textAppearance="@style/TextAppearance.AppCompat.Body1"
    android:textSize="30sp"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.503"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
"
android:textStyle="bold"
android:typeface="normal"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="24dp"
    android:onClick="sortearNumero"
    android:text="Jogar"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/textView" />

<TextView
    android:id="@+id/textoResultado"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="316dp"
    android:layout_marginTop="32dp"
    android:text="Nenhum numero selecionado"
    android:textSize="24sp"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.507"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/button"
    app:layout_constraintVertical_bias="0.0" />

<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="16dp"
    android:layout_marginEnd="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginStart="16dp"
    android:layout_marginTop="16dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.504"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/textoResultado"
    app:srcCompat="@drawable/img_principal" />

************************* JAVA ********************* ******************

package com.example.jordansilva.sorteio;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import java.util.Random;

    public class MainActivity extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }

        public void sortearNumero(View view) {
            TextView textoResultado = findViewById(R.id.textoResultado);

            int x = new Random().nextInt(61);
            textoResultado.setText("O numero sorteado foi: " + x);
        }
    }
    
asked by anonymous 06.06.2018 / 16:54

1 answer

0

Try to clean your project ( Build > Clean Project ) and compile it again

    
06.06.2018 / 18:14