重命名Android Studio中的程序包 [英] Renaming package in Android Studio

查看:94
本文介绍了重命名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天全站免登陆