I'm having trouble opening an activity fragment

1

I'm using trying to set up a floating button for this action:
Xml:

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".PostScreen">


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/floatingActionButton"
        android:layout_gravity="bottom|end"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:clickable="true"
        android:focusable="true"
        app:srcCompat="@color/colorAccent"
        android:src="@drawable/add_symbol"
        android:onClick="addPost"/>

</android.support.constraint.ConstraintLayout>

This is the Java of this Xml:

package com.example.cliente.postit;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class PostScreen extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_screen);
    }
    public void addPost (View view){
        Intent post = new Intent(PostScreen.this, postActivity.class);
        startActivity(post);
    }
}

I had to manually add this line in Gradle to format the button

implementation 'com.android.support:design:27.1.1'

This is the Log that is generated from the error:

05-08 16:56:43.712 2049-2049/com.example.cliente.postit W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa6698228)
05-08 16:56:43.712 2049-2049/com.example.cliente.postit E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
    at android.view.View$1.onClick(View.java:3591)
    at android.view.View.performClick(View.java:4084)
    at android.view.View$PerformClick.run(View.java:16966)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at android.view.View$1.onClick(View.java:3586)
    at android.view.View.performClick(View.java:4084) 
    at android.view.View$PerformClick.run(View.java:16966) 
    at android.os.Handler.handleCallback(Handler.java:615) 
    at android.os.Handler.dispatchMessage(Handler.java:92) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:4745) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:511) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    at dalvik.system.NativeStart.main(Native Method) 
 Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.cliente.postit/com.example.cliente.postit.postActivity}; have you declared this activity in your AndroidManifest.xml?
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
    at android.app.Activity.startActivityForResult(Activity.java:3351)
    at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:68)
    at android.app.Activity.startActivityForResult(Activity.java:3312)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:751)
    at android.app.Activity.startActivity(Activity.java:3522)
    at android.app.Activity.startActivity(Activity.java:3490)
    at com.example.cliente.postit.PostScreen.addPost(PostScreen.java:17)
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:511) 
    at android.view.View$1.onClick(View.java:3586) 
    at android.view.View.performClick(View.java:4084) 
    at android.view.View$PerformClick.run(View.java:16966) 
    at android.os.Handler.handleCallback(Handler.java:615) 
    at android.os.Handler.dispatchMessage(Handler.java:92) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:4745) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:511) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    at dalvik.system.NativeStart.main(Native Method) 
05-08 17:01:43.772 2049-2049/? I/Process: Sending signal. PID: 2049 SIG: 9
    
asked by anonymous 08.05.2018 / 19:11

1 answer

0
  

Caused by: android.content.ActivityNotFoundException: Unable to find   explicit activity class   {com.example.client.postit / com.example.client.postit.postActivity};    Have you declared this activity in your AndroidManifest.xml?

public void addPost (View view){
        Intent post = new Intent(PostScreen.this, postActivity.class);
        startActivity(post);
}

I should also ask, have you stated postActivity in AndroidManifest?

    
09.05.2018 / 20:49