在 Android Studio 中重命名包 [英] Renaming package in Android Studio

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

问题描述

我正在尝试按照第一个答案中的描述重命名我的 Android Studio 包:Android Studio 重命名包

I am trying to rename my Android Studio package as described in the first answer at: Android Studio Rename Package

尝试将 org.springframework.android.showcase 更改为 org.springframework.android.showcase2

Trying to change org.springframework.android.showcase to org.springframework.android.showcase2

重构似乎工作正常,然后我尝试删除/gen/org.springframework.android/showcase 中的旧包.这确实发生,但随后又重新出现(在/gen/org.springframework.android/showcase 中)

The refactoring seemly works fine, then I try delete the old package within /gen/org.springframework.android/showcase. This does occur but then it reappears (Within /gen/org.springframework.android/showcase)

在编译时,我遇到了 100 多个错误,所有错误都与 R.java 文件引用有关.

When compiling I get over a 100 errors all related to the R.java file references.

将 R.java、Manifest.java 从原始复制到新的也不起作用.Studio 只是删除这些但保留 BuildConfig.java 文件.

Copying the R.java, Manifest.java from the original to the new does not work either. Studio simply deletes these but leaves the BuildConfig.java file.

有没有更简单的方法,因为 Studio 似乎不想打球?

以下是我的项目结构,以防万一

Below is my Project structure in case it's helpful

推荐答案

您看到带有旧包名的生成文件的原因是因为您只重命名了源代码包.生成的文件使用在 AndroidManifest.xml 中定义的包名.如果您也更改清单顶部的包,您将看到生成的文件使用新包.确保清理项目并重新构建以查看更改.

The reason you are seeing the generated files with the old package name is because you only renamed the source code package. The generated files use the package name defined in the AndroidManifest.xml. If you change the package at the top of the manifest as well you will see the generated files use the new package. Make sure to clean the project and rebuild to see the changes.

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

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