我想更改我的项目和模块的名称。但如果我试图重命名他们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 Studio 再次导入整个项目

修改包名称。

最简单和最快的解决方案在这里:https://stackoverflow.com/a/35057550/4908798

其他回答

以下是我在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,我的包名称现在已经更改并成功构建。

您可以在设置中尝试类似的操作。gradle文件:

rootProject.name = "YOUR_PROJECT_NAME"

重新启动Android Studio后,它也将改变标题栏中的文本为YOUR_PROJECT_NAME。

在Android Studio 2.2 RC2上测试

只要去res>values>strings.xml。一行说 Somethig-your名字

<string name="app_name">Somethig-your name</string>

把你原来的名字换成

 <string name="app_name">Your Name</string>

您可以轻松地使用refactor重命名。

写,单击项目根文件夹,然后单击重构。 然后点击重命名,会弹出一个窗口,你可以在那里给出新的名字。

这对我来说很管用:

关闭Android Studio 重命名项目根目录名称 Open Android Studio 打开项目 清洁项目

如果你的设置。Gradle包含下面的行,要么删除它,要么将其更新为新名称。

rootProject.name = 'Your project name'

编辑: 工作在所有版本!最后一次测试:2022年6月Android Studio黑猩猩。