尝试在 Android Studio 中重命名包,但表示文件 (com) 已存在 [英] Trying to rename a package in Android Studio but says file (com) already exists

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

问题描述

我在 Android Studio 中创建了一个新应用程序,一切正常,我创建了一个签名的 apk,但是我在 Play 商店上发布了一个旧应用程序,我设法找到了那个旧应用程序的 key.keystore,这是我最初所做的两年前在 Eclipse 中,所以在 Keystore Explorer 中打开我的旧 apk 后,我能够记住我的旧存储密码、别名和密钥密码,所以我回到 Android Studio,单击 Generate New Signed apk,我选择了我的旧密钥库路径,填写信息(存储密码、别名、密钥密码,它让我用旧的 key.keystore 生成新的签名 apk,所以我假设我实际上用旧的 Eclipse 密钥签名了新的 AS 应用程序.密钥库,否则它不会让我生成一个签名的 apk 对吗?或者在模拟器中运行它,直到我输入正确的信息.

I created a new app in Android Studio, everything went fine, I created a signed apk, but I have an old app on Play Store published, I managed to locate the key.keystore for that old app, which i originally did in Eclipse two years ago, so after opening my old apk in Keystore Explorer, I was able to remember my old store password, alias and key password, so I went back into Android Studio, clicked Generate New Signed apk, I selected my old keystore path, filled in the info (store password, alias, key password, and it left me generate the new signed apk with the old key.keystore, so I'm assuming I actually got the new AS app signed with my old Eclipse key.keystore or it wouldn't have left me generate a signed apk right? or run it in emulator until I entered the correct info.

现在我遇到的下一个问题是重命名包,我需要做的是将新的应用程序/包重命名为与旧应用程序/包相同的名称 (com.name.radio) 我读到你这样做了这在 build.gradle ..... 当我在 AS 创建我的新应用程序时,我能够首先重命名 java 下的 3 个文件夹,没有问题(命名.ie.radio)来做到这一点,我选择了我想要的文件夹要重命名,请单击显示选项菜单",取消选中压缩空中间包",右键单击我的文件夹 &选择重构 > 重命名 > 重命名包,然后我不得不在 build.gradle 中更正它,第一次工作正常.

Now the next problem I'm having is renaming the package, what I need to do is rename the new app/package to the same name as the old app/package (com.name.radio) I read that you do this in the build.gradle..... When I created my new app in AS I was able to renam the 3 folders under java first with no problems (to name.ie.radio) to do this I select the folder I want to rename, click Show Options Menu, untick Compact Empty Middle Packages, right click my folder & select Refactor > Rename > Rename Package, then I had to correct that in the build.gradle, worked fine the first time.

现在我想再次将我的新应用程序/包重命名为与我的旧应用程序相同的名称(com.name.radio),因此我尝试将新包名称设置为 com,但它不允许我说文件已存在.http://i.stack.imgur.com/cNgA5.png

Now I want to rename my new app / package again, to the same name as my old app (com.name.radio) so I tried setting new package name to com, but it doesn't allow me, saying that file already exists. http://i.stack.imgur.com/cNgA5.png

我是否应该删除位于以下位置的 com 文件夹:\app\build\generated\source\r\release尝试在 build.gradle 中重命名它是没有意义的,对吧?

Should I delete the com folder at: \app\build\generated\source\r\release There's no point in trying to rename it in the build.gradle yet right?

有人帮助我,就像每天晚上都在猜测一样.我只想发布对旧应用的更新,而无需发布新应用.

Someone help me out here it's like a guessing every night. I just want to publish an update to my old app without having to publish a fresh app.

推荐答案

这个修改需要三步:

  1. 更改清单中的包名称
  2. 在树视图中右键重构你的包的名称->重构->重命名,然后Android studio会显示一个窗口,选择重命名包"
  3. 手动更改 build.gradle 文件中的应用程序 ID : android/defaultconfig/应用程序 ID 然后清理/重建项目

根据这个答案

这篇关于尝试在 Android Studio 中重命名包,但表示文件 (com) 已存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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