Manifesto:

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.comp.physics.FavoritesActivity" android:label="@string/favorites_title"> </activity> </application> 

MainActivity.java:

 package com.example.comp.physics; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void onClick(View view) { Intent intent = new Intent(MainActivity.this, FavoritesActivity.class); // <----- startActivity(intent); } } 

FavoritesActivity.java:

 package com.example.comp.physics; import android.app.Activity; import android.os.Bundle; public class FavoritesActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_favorites); } } 

When I click on the button I get an error:

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.comp.physics / com.example.comp.physics.FindingActivity}; have your AndroidManifest.xml?

What did I miss?

  • 2
    I think you need to do a project rebuild - Vladyslav Matviienko
  • @metalurgus, thank you very much, you had to really just rebuild the project! - Ilya Bizunov

1 answer 1

  1. Try to inherit the second activit also from AppCompatActivity instead of just Activity.

  2. Another option is to prescribe in the manifest not the entire name, but an abbreviation, as in the case of the first activation:

     <activity android:name=".FavoritesActivity" android:label="@string/favorites_title"> </activity> 
  3. Also, perhaps the point is in the studio’s instantRun function — try turning it off in the settings.