我想更改我的项目和模块的名称。但如果我试图重命名他们Android工作室通知我一些错误…
例:我想把名字从“MyApplication”改为“AndroidApp”,如下图所示。
在第一个矩形中,我想改变它:
AndroidApp (“G:...\Android\AndroidApp”).
在第二个矩形中,我想改变它:
AndroidApp [AndroidApp-AndroidApp]
编辑:这是日志:
Gradle:项目“AndroidApp”在根项目“MyApplicationProject”中找不到。
build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
settings.gradle:
include ':MyApplication'
这对我来说没问题
Change Following.
步骤1:确保ApplicationId和PackageName相同。
例子:
android {
defaultConfig {
applicationId "com.example.myapplication"
}
}
and package name the same. package="com.example.myapplication"
步骤2
删除iml文件在我的情况下:
Go To Project> >C:\Users\ashif\Documents\MyApplication .iml file // delete
if you forget Project Path Then Go To android Studio Right Click on app and go to Show in Explorer you get your Project and remove .iml file
步骤3
关闭项目
步骤4
现在复制您的旧项目,并粘贴任何其他根或复制项目文件夹,并粘贴任何
其他的意外死亡。
Example C:\Users\ashif\Documents/MyApplication
步骤5
Now open Android Studio and open Existing Project
C:\Users\ashif\Documents/MyApplication
尝试一下就会成功
它为我工作的方式,以取代我的项目的旧名称为一个新名称(在我的代码库中无处不在)如下:
Close Android Studio.
Rename the root folder of your project.
Open Android Studio. It will not find the old project, so you must import it again. This step will generate the configuration again (no need to touch your .idea files manually), including a new .iml file with the new project name. Afterwards you can delete the old .iml file if you want.
Once the renamed project is imported in Android Studio you need to rename your source packages to use the new project name in case you used the old project name as part of the package path.
注意:这适用于Android Studio 2.1.2
更新:
这个答案更好。
旧的回答:
1. 右击你的
包名和重构->重命名…
当被问到是要重命名目录还是重命名包时,选择“重命名包”
现在在Finder中,手动重命名你的根文件夹(/app文件夹的父文件夹)
在Android Studio中用新的文件夹名称重新打开项目
Cmd + Shift + f为你的旧名称在Android Studio的任何实例,并将它们全部更改为新名称。
在build.gradle中更改applicationId
奖金轮:
如果.gitignore文件位于项目的根目录,则可能需要更新它。请注意,在完成此操作后交换分支时,您可能会在工作更改中看到一堆文件,但不用担心,在您将重新命名的分支与更新的.gitignore合并后,它们应该会消失。不要手动删除这些,因为这会导致Android Studio出现问题。
在Finder中删除旧的根文件夹