美文网首页Android
Android Studio rename a package

Android Studio rename a package

作者: JaedenKil | 来源:发表于2021-03-25 10:52 被阅读0次

    Simple scenario: Need to rename a package, say from com.aa.bb to com.cc.dd.

    The usual method won't work: In project panel, choose package folder, refactor - rename, which will only rename the last part of the package name.

    Solution:

    1. In AS top-left corner, choose Project panel
    2. Right next to Project panel, click on the settings logo
    3. In the new option list, uncheck Compact Middle Packages
    4. Apply Refactor-Rename for each folder
    5. After rename, check the Compact Middle Packages
    6. Manually update the applicationId in module level build.gradle

    Finally, there may be code related with the old package name, to verify that:

    1. rm -rf app/build
    2. grep -r "originalPackageName" . 2>/dev/null

    If there is output for step 2, maybe related code needs update.

    相关文章

      网友评论

        本文标题:Android Studio rename a package

        本文链接:https://www.haomeiwen.com/subject/qzelhltx.html