简体   繁体   English

Android Studio 看不到 MainActivity

[英]Android Studio can not see MainActivity

This is a new project created by the android studio.这是由 android 工作室创建的新项目。 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.我在这个项目中没有改变任何东西,但是在activity_main.xml文件中,MainActivity.java找不到,而且这个project.Z93F725A07423FE1C8846F448B3D21文件中有一个MainActivity.Z93F725A07423FE1C8846F448B3D21 How I can make this run.我怎样才能做到这一点。 (MainActivity.java see activity_main.xml as related ) (MainActivity.java 见 activity_main.xml 相关)

在此处输入图像描述

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.如果不起作用,请尝试重新启动 Android studio。

It's not get accourate path of your package.它没有得到 package 的准确路径。 You can Use com.example.myapplication.MainActivity that times it's work properly.您可以使用com.example.myapplication.MainActivity时间它可以正常工作。

OR或者

Invalid caches/restart android studio.无效的缓存/重启 android studio。

Add your activity to AndroidManifest.xml under <application>将您的活动添加到<application>下的AndroidManifest.xml

 <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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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