简体   繁体   English

无法重构Android Studio项目

[英]Cannot refactor Android Studio Project

I have copied a current project of Android Studio to a new directory. 我已将Android Studio的当前项目复制到新目录。 I will be using the same coding for another app. 我将对另一个应用程序使用相同的编码。

I open the project in Android Studio, and click on the "Java" folder, but it doesn´t show any files inside (they do appear in the hard-drive). 我在Android Studio中打开该项目,然后单击“ Java”文件夹,但其中没有显示任何文件(它们确实出现在硬盘驱动器中)。

When I click to "Refactor" the "Java" folder the following message appears "Cannot perform refactoring. Selected directory is not located inside project". 当我单击“重构”时,“ Java”文件夹将显示以下消息:“无法执行重构。所选目录不在项目内部”。

Can someone help me to solve this, thanks. 有人可以帮我解决这个问题吗,谢谢。

You had imported the project in a non-empty directory. 您已将项目导入到非空目录中。

Follow the following steps: 请按照以下步骤操作:

Suppose you want to cope a project Named: MyProject1 假设您要处理一个名为MyProject1的项目

  1. Copy the Project from its directory and paste in an empty folder. 从其目录复制项目,然后粘贴到一个空文件夹中。

  2. Make sure you have closed the MyProject1 from Android Studio by clicking Files>>Close Project 通过单击文件>>关闭项目,确保已从Android Studio关闭了MyProject1。

  3. Click on the Open an Existing Android Studio Project 单击“ 打开现有的Android Studio项目”

  4. Locate the new directory, where you have pasted the MyProject1 folder. 找到新目录,您将MyProject1文件夹粘贴到了该目录。 Recheck if " MyProject1 " folder itself contains the "MyProject1" folder then it will not work. 重新检查“ MyProject1 ”文件夹本身是否包含“ MyProject1”文件夹,则它将不起作用。

  5. Now select the MyProject1 folder and go ahead. 现在选择MyProject1文件夹并继续。

  6. It will start the gradle build. 它将开始构建gradle。

  7. After successfull build the you can start refactoring. 成功构建之后,就可以开始重构了。

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

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