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

查看:184
本文介绍了尝试在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).当我在AS中创建我的新应用时,我能够毫无问题地重命名java下的3个文件夹(以name.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/application ID,然后清理/重建项目

根据此 answer

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

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