Android的工作室重命名包 [英] Android Studio Rename Package

查看:222
本文介绍了Android的工作室重命名包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在新的IDE的Andr​​oid工作室命名的包,基于intelijj?

有没有自动重构包括在内?

我要进行大量的重构,但我不知道怎么办。我工作2年日食和月食它的点击操作。

解决方案

在Android的工作室,你可以这样做:

例如,如果你想改变 com.example.app <​​/ code>到 my.awesome.game ,然后

  1. 在您的项目窗格,点击小齿轮图标(

  2. 取消选中/取消选择紧凑型空中间包选项

<醇开始=3>
  • 您封装目录将现在各个目录被分解

  • 单独选择要重命名的每个目录和:

    • 右键点击
    • 选择重构
    • 点击重命名
    • 在弹出的对话框中,单击重命名包而不是重命名目录
    • 输入新的名称,点击重构
    • 允许一分钟,让Android的Studio更新所有更改
    • 注意:在机器人工作室更名 COM ,它会给出警告。在这种情况下,选择全部重命名
  • 现在,打开你的摇篮构建文件(build.gradle <$ C C $> - 通常应用移动)。更新的applicationID 到新的包名称和同步摇篮,如果尚未自动更新:
  • <醇开始=6>
  • 完成!不管怎么说,Android的工作室需要使这个过程变得更简单。
  • How do you rename packages in new IDE Android Studio, based on intelijj ?

    Is there any automatic refactoring included?

    I want to make bulk refactoring but I don't know how. I worked 2 years with eclipse and in eclipse it's one click operation.

    解决方案

    In Android Studio, you can do this:

    For example, if you want to change com.example.app to my.awesome.game, then:

    1. In your Project pane, click on the little gear icon ( )

    2. Uncheck / De-select the Compact Empty Middle Packages option

    1. Your package directory will now be broken up in individual directories

    2. Individually select each directory you want to rename, and:

      • Right-click it
      • Select Refactor
      • Click on Rename
      • In the Pop-up dialog, click on Rename Package instead of Rename Directory
      • Enter the new name and hit Refactor
      • Allow a minute to let Android Studio update all changes
      • Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All

    1. Now open your Gradle Build File (build.gradle - Usually app or mobile). Update the applicationId to your new Package Name and Sync Gradle, if it hasn't already been updated automatically:

    1. Done! Anyways, Android Studio needs to make this process a little simpler.

    这篇关于Android的工作室重命名包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆