如何在基于IntelliJ IDEA的新IDE Android Studio中重命名软件包?

是否包含自动重构?

我想进行大规模重构,但我不知道怎么做。我在Eclipse工作了两年,在Eclipse中它是一个一键操作。


当前回答

对我来说会很好的

Change Following.

步骤1:确保ApplicationId和PackageName相同。例子:

  android {
  defaultConfig {
                     applicationId "com.example.myapplication"
                 }
       }
 and package name the same. package="com.example.myapplication"

步骤2在我的案例中删除iml文件:

  Go To Project> >C:\Users\ashif\Documents\MyApplication  .iml file // delete 
if you forget Project Path Then Go To android Studio Right Click on app and go to  Show in Explorer you get your Project and remove .iml file

步骤3关闭项目

步骤4现在复制您的旧项目并粘贴任何其他根或复制项目文件夹并粘贴任何其他董事。

 Example C:\Users\ashif\Documents/MyApplication 

步骤5

Now open Android Studio and open Existing Project 
C:\Users\ashif\Documents/MyApplication 

试试看会奏效的

其他回答

首先,您需要转到左侧显示的设置图标。单击该下拉列表并取消选中压缩空中间包

转到AndroidManifest.xml

选择所有包,然后右键单击重构,然后根据需要重命名。然后转到build.gradle,然后使用Android Manifest中的packagename更改Applicationid。

这对我来说很有效

要在Android studio中重命名包名,请单击项目部分中的设置图标并取消选中压缩空中间包,然后包将拆分为多个文件夹名,然后右键单击需要更改名称的文件夹,单击refactor->rename->Type the name you want To change in->refactor-->refactor Directory,然后在整个项目中导入R.java文件。为我工作。

第一部分包括在java文件夹下创建一个新包,然后选择并将所有源文件从旧包拖到这个新包。之后,您需要将android manifest中的包名称重命名为新包的名称。在步骤2中,这是您需要做的。除了更改清单中的包名之外,您还需要更改android studio中模块build.gradle下applicationId中的旧包名。总之,单击“AndroidManifest.xml”下面的build.gradle并将applicationId的值修改为新的包名。然后,在顶部,建造不足。清理项目,然后重建。从这里开始应该很好。

如何将com.example.app重命名为com.android.app:

在包com.example.app中选择示例移位+F6选择重命名包将示例重命名为android确认进行重构

ctrl+Shift+R一直对我有效。只需替换所有文件并选择所有文件。