简体   繁体   中英

Android Studio can not see MainActivity

This is a new project created by the android studio. I did not change anything in this project, but in the activity_main.xml file, MainActivity.java can not find, and there is a MainActivity.java file in this project. How I can make this run. (MainActivity.java see activity_main.xml as related )

在此处输入图像描述

If you really haven't made any changes prior to this happening, try cleaning and rebuilding the project in the build tab. If it doesn't work, try restarting Android studio.

It's not get accourate path of your package. You can Use com.example.myapplication.MainActivity that times it's work properly.

OR

Invalid caches/restart android studio.

Add your activity to AndroidManifest.xml under <application>

 <activity android:name=".MainActivity" >
        <intent-filter>
      <!-- MAIN represents that it is the Main Activity-->
            <action android:name="android.intent.action.MAIN" />
      <!-- Launcher Denotes that it will be the first launching activity-->
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM