I just built a very simple app and tried to test it. The app just contains a button (for now), clicking which opens another activity. Here's the error I get:
Unable to find explicit activity class {com.example.mathshelper/com.example.mathshelper.peri_area_rect}; have you declared this activity in your AndroidManifest.xml?
Here's my androidmanifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mathshelper">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
How to fix it?
Edit: here's the activity class code:
package com.example.mathshelper
import android.content.Intent
import android.os.Bundle
import com.google.android.material.snackbar.Snackbar
import androidx.appcompat.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.content_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
goToPeriAreRctangle.setOnClickListener {
startActivity(Intent(this, peri_area_rect::class.java))
}
}
}
EDIT: I am very sorry guys, I was following a wrong approach to add a new activity, basically, I should have gone to File > New > Activity.