我想更改我的项目和模块的名称。但如果我试图重命名他们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'

当前回答

只需从android Manifest中找到名称“android:label="AppName"”。 只需重命名标签名称(例如:“AppName”这里)所有这样的android:标签在AndroidManifest.xml。省省吧!当你运行应用程序时,你会看到新的名称

其他回答

以下是我在Android Studio Beta(0.8.14)中所做的事情

Changed the package name manually in the manifest file Navigated to build -> source -> r -> release and drilled down until I found R.java Selected the file and pressed F6 to rename Then from the Build menu selected Make Project Clicked the first error and pressed Shift+F6 on the package name and renamed which updated all my source files Selected my project name in Android Studio, right clicked -> Refactor -> Rename and changed the name there too. Next went to app -> build.gradle and updated my applicationId Navigate to .idea -> .name file and rename your Android Studio project in there too Just to clean up I deleted the old package folder inside build -> source -> r -> release

和vola,我的包名称现在已经更改并成功构建。

更新2017年7月:测试和工作


打开项目文件夹(你可以通过Android Studio打开它) 现在关闭Android Studio 更改yourOldProjectName。我有了一个新名字 将父文件夹重命名为相同的新名称。 重新打开Android Studio—> File—>打开—>路径到你的重命名。im

它为我工作的方式,以取代我的项目的旧名称为一个新名称(在我的代码库中无处不在)如下:

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

关闭Android Studio。 重命名项目根目录的文件夹。例如,将“MyApplication”更改为“Myblablabla”。 删除'。想法的文件夹。 打开Android Studio,导入更新后的项目。

1.编辑设置。gradle文件,更改rootProject.name

rootProject.name = "FirebaseDemo"
include ':app'

2.进入项目文件夹,重命名文件夹

3.删除项目中的。idea文件夹并重新构建项目