突然我发现了以下错误:
android.content.activityNotFoundException:找不到显式活动类。
尽管我已经在文件中声明了我的应用程序的所有活动。
有人知道如何修正这个错误吗?
谢谢大家

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uniparthenope.jacoe.homework_tmm">
<uses-feature android:name="android.hardware.camera"
              android:required="true"/>

<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">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".SignUpActivity"
        android:parentActivityName=".MainActivity">
    <!-- The meta-data tag is required if you support API level 15 and lower -->
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".MainActivity"/>
</activity>
</application>

</manifest>

这是我的AndroidManifest.xml,在这里我通过一个意图调用活动MainActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

private TabLayout tabLayout;
private ViewPager viewPager;

ChatFragment chatFragment;
CallsFragment callsFragment;
StatusFragment statusFragment;
PhotoFragment  photoFragment;

String[] tabTitle = {"FOTO", "CHIAMATE", "CHAT", "STATO"};
int[] unreadCount = {0, 0, 5, 0};

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

    Toolbar toolbarapp = (Toolbar) findViewById(R.id.Whatsapp_tmm_toolbar);
    setSupportActionBar(toolbarapp);


    viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setOffscreenPageLimit(4);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.tablayout);
    tabLayout.setupWithViewPager(viewPager);

    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            viewPager.setCurrentItem(position, false);

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_button, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
        case R.id.login:
             Intent login = new Intent(this, SignUpActivity.class);
             startActivity(login);
             finish();
             return true;

最佳答案

尝试与android studio中的“同步gradle文件的项目”同步->文件->同步gradle文件的项目。
有时我们会在对清单进行更改后错过执行此操作。

09-12 03:55