简体   繁体   English

Android工作室-看不到Java目录

[英]Android Studio - Can't see Java Directory

  1. Created new project in Android Studio on the desktop.在桌面上的 Android Studio 中创建了新项目。
  2. in the Android view in the Project Explorer all looked normal.在 Project Explorer 的 Android 视图中看起来一切正常。
  3. Moved the project to a new folder on the desktop and opened it in Studio.将项目移动到桌面上的新文件夹并在 Studio 中打开它。
  4. Now in the Android view in the project explorer there is no dropdown icon on the Java directory.现在,在项目资源管理器的 Android 视图中,Java 目录上没有下拉图标。
  5. I have invalidated caches, cleaned the project and probably a couple of other things I have forgotten, still cannot see my source files.我已经使缓存失效,清理了项目,可能还有一些我忘记的其他事情,但仍然看不到我的源文件。

I tried both copy and move using file explorer in win7.我尝试在 win7 中使用文件资源管理器进行复制和移动。

I have faced the same issue, although @Igor answers fix your issue, it was different for me because the Java files are missing in the file directory.我遇到了同样的问题,虽然@Igor 的回答解决了你的问题,但对我来说是不同的,因为文件目录中缺少 Java 文件。 Same as you, I've also followed the same steps from https://developer.android.com/training/basics/firstapp/creating-project.html and there's nothing special with those steps.与您一样,我也按照https://developer.android.com/training/basics/firstapp/creating-project.html中的相同步骤进行操作,这些步骤没有什么特别之处。

I have resolved the issue by downloading the SDK quck fix in the "Messages Gradle Sync" explorer.我通过在“消息 Gradle 同步”资源管理器中下载 SDK 快速修复解决了这个问题。

在此处输入图像描述

After that, the java folder will appear to the project explorer.之后,java 文件夹将出现在项目资源管理器中。 在此处输入图像描述

I've faced a similar issue: I could see my java directory in the Android view, but not in the Project view.我遇到过类似的问题:我可以在 Android 视图中看到我的 java 目录,但在项目视图中看不到。 I finally managed to fix it by going in the menu: File > Sync Project With Gradle Files.我终于设法通过进入菜单来修复它:文件 > 将项目与 Gradle 文件同步。

Hope it helps someone.希望它能帮助别人。

Your top-level project in Android Studio should show the absolute path of the directory on your machine.您在 Android Studio 中的顶级项目应该显示您计算机上目录的绝对路径。 Look in the Project perspective (not Android perspective).查看项目透视图(不是 Android 透视图)。 Like D:\workspace\myproject .D:\workspace\myproject Go ahead and navigate into that directory with file explorer on your machine, and make sure that its java sub-directory contains classes! Go 并使用您机器上的文件资源管理器导航到该目录,并确保其 java 子目录包含类!

If you are using a library project, then you need to add below lines in gradle library level如果您使用的是图书馆项目,则需要在 gradle 图书馆级别添加以下行

android {
sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

and you need to change the word kotlin to java according to folder name you already have.并且您需要根据您已有的文件夹名称将单词kotlin更改为java

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

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