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

当前回答

TL; diana:

你可能只关注最后一部分重命名,可能只有图像在里面…: -)


术语:

Android Studio的“项目名称”是不存在的。但它们是在创建新项目时输入的其他名称:

应用程序名称,最初与Gradle的根项目名称相同, 包名, Android Studio项目根文件夹名称。

一般来说,人们想要改变这3个名称,大多数是从Gradle的根项目名称中派生出来的,就像在新建项目对话窗口中建议的那样。

所以我的答案会涵盖这种情况。


分析:

在创建新项目时,我们可能需要遵循与Android Studio相同的步骤。

如果你选择文件→新建→新建项目…(然后是一个项目模板),在新建项目对话框窗口的第一个字段是“名称”字段提供的名称My Application。

2个next字段使用这个(默认的或已更改的)名称派生其他2个字符串的默认名称,例如,有3个重要的字符串

我的应用程序 com.something.myapplication C:\Users\someuser\ AndroidStudioProjects \ MyApplication

此外,

在创建项目之后,还没有构建会使用这3个字符串。


重命名:

因此,在重命名为其他名称期间,我们必须确保4件事-我将使用My改名项目的名称作为新名称的基础。

让我们从最后一个,可能是最简单的一个开始:

Build ->清洁项目

从现在开始,在完全重命名完成之前,请不要进行新的构建。

现在,开始重命名之前指定的3点:

My Application: In the leftmost position of the title bar of the Android Studio Window, you see the same text as I selected in the settings.gradle file: Change this text to the new name (My Renamed Application). The yellowish bar will appear near the top. Click the “Sync Now” in the right-hand part of it:         You will immediately see the change in the title bar: You probably want to change the application name to the same name, too, so change it in the strings.xml resource file (the change will then reflect in the AndroidManifest.xml file, which is important): Before renaming: After renaming:   com.something.myapplication: Change the applicationID in the build.gradle (module level) file - the new name, derived from “My Renamed Application” will be without spaces, all lowercase, i.e. myrenamedapplication: Before changing: After changing: The yellowish bar will appear again near the top. Click the “Sync Now” in the right-hand part of it:           Now close the Android Studio, and rename the folder MyApplication (probably located in the folder C:\Users\someuser\AndroidStudioProjects\) to MyRenamedApplication (the name, derived from “My Renamed Application”, is without spaces). Although this step is optional, it is highly recommended to keep things tidy.

注意:

使用File→Open Recent打开重命名的项目当然会失败,所以在重命名后,第一次使用File→Open打开它。

其他回答

->修改项目名称<-


通过关闭Android Studio更改项目名称,进入项目文件夹,重命名它…



删除。idea文件夹和。iml文件。(要显示隐藏的文件夹,按Cmd + Shift +。(点))。



打开设置。使用文本编辑器(如VSCode)编辑gradle文件,并将rootProject.name更改为您的新项目名称。



完成了!项目名称已更改!只要用Android Studio打开你的项目,Gradle就会再次同步。

你好罗伯托AV96,

我在这里提供了三个解决方案。选择一个适合你的问题。

如果您只想更改项目根文件夹的名称 名称,你可以从资源管理器:

Just close the project in the studio, after copying path to the project. Close the project from the main welcome screen. go to the file explorer, copy this path on the address bar, and go to the folder. Rename the folder that is the root of the project. Rename the iml file in this root folder to the name of the folder. That is if the project root folder's name was say demo_project, there will be demo_project.iml file inside it. If you changed this folder's name to say my_project, then you have to change the name of the iml file inside it to my_project.iml.

实际上,Studio中的重构选项也可以做到这一点。

如果要更改应用程序文件夹的名称,则在 项目的根文件夹,在资源管理器中执行同样的操作:

将app文件夹重命名为您想要的名称。

[信息:为这个项目生成的APK文件将 获取相同的名字,后跟表示 你构建签名APK的模式,即调试或 释放。签名的APK可以在它各自的调试或发布文件夹中找到。unsigned APK位于build目录的output文件夹中,所有的build, debug和release文件夹都在主app文件夹中,或者你将这个文件夹重命名为]的文件夹中。

假设你给这个文件夹取的名字是my_project_app,打开这个文件夹并将app.iml重命名为my_project_app。我在项目的名字后面。 现在转到项目的根文件夹,并找到设置。gradle文件。

这个文件的内容是你在项目中包含的模块文件夹的名称,目前只有一个模块,那就是主模块:

include ':app'

这对应于app文件夹的旧名称。

因此你必须做出以下改变:

include ':my_project_app'

就是这样。现在您可以在工作室中重新加载项目,并检查生成的APK的名称。

如果要重命名包名,请输入com.first.myproject to com.alpha.myproject:

Again go to the explorer: Inside the hierarchy of folders in the src-->main-->java, your package is com-->first-->myproject. Make sure your Studio is closed. Rename the second folder first to alpha. Open the Studio now. Choose Replace in Path in the first package inside the java folder, in the Android mode of the left panel tree. This one is the package that you changed from the Explorer, that is: com.alpha.myproject instead of com.first.myproject. Change the instances of the string import com.first.myproject; in files to import com.alpha.myproject;. Check for just the string occurrence of com.first.myproject, and safely change it to com.alpha.myproject. Check for just the string occurrence of com.first.myproject, in build.gradle inside your main app module, and safely change it to com.alpha.myproject. Do not forget that this package name is also the signature and identity to your application project. If you have already published your application in the play store, then you have to setup a different project com.alpha.myproject afresh and unpublish com.first.myproject, affecting lots of users:- you have to broadcast to the users using push notification, in the latest version of old existing APK, that the new Application version will be released with different name, and you have to publish this new APK, restarting from version name 1.0. This destroys objective of having the application slot at play-store for the old APK. So you have to consult your client that what should be the name of their application package before starting the project. Don't forget that the signing and obfuscation of the application is equally important. You can issue command inside Studio to remove unnecessary resources from your project. You can manually deal with all the warnings that LINT produces.

快乐编码和快乐应用程序发布。: -)

对我来说,以下工作:

关闭Android Studio。 将项目的文件夹从MyApplication重命名为NewProjectName 重命名MyApplication。iml文件到NewProjectName.iml 在NewProjectName。iml将每个MyApplication文本更改为NewProjectName 在.idea/modules.xml中将每个MyApplication文本更改为NewProjectName 在.idea/workspace.xml中将每个MyApplication文本更改为NewProjectName 启动Android Studio。 所有之前的设置保持不变,“app”模块也一样!

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

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

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

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

TL; diana:

你可能只关注最后一部分重命名,可能只有图像在里面…: -)


术语:

Android Studio的“项目名称”是不存在的。但它们是在创建新项目时输入的其他名称:

应用程序名称,最初与Gradle的根项目名称相同, 包名, Android Studio项目根文件夹名称。

一般来说,人们想要改变这3个名称,大多数是从Gradle的根项目名称中派生出来的,就像在新建项目对话窗口中建议的那样。

所以我的答案会涵盖这种情况。


分析:

在创建新项目时,我们可能需要遵循与Android Studio相同的步骤。

如果你选择文件→新建→新建项目…(然后是一个项目模板),在新建项目对话框窗口的第一个字段是“名称”字段提供的名称My Application。

2个next字段使用这个(默认的或已更改的)名称派生其他2个字符串的默认名称,例如,有3个重要的字符串

我的应用程序 com.something.myapplication C:\Users\someuser\ AndroidStudioProjects \ MyApplication

此外,

在创建项目之后,还没有构建会使用这3个字符串。


重命名:

因此,在重命名为其他名称期间,我们必须确保4件事-我将使用My改名项目的名称作为新名称的基础。

让我们从最后一个,可能是最简单的一个开始:

Build ->清洁项目

从现在开始,在完全重命名完成之前,请不要进行新的构建。

现在,开始重命名之前指定的3点:

My Application: In the leftmost position of the title bar of the Android Studio Window, you see the same text as I selected in the settings.gradle file: Change this text to the new name (My Renamed Application). The yellowish bar will appear near the top. Click the “Sync Now” in the right-hand part of it:         You will immediately see the change in the title bar: You probably want to change the application name to the same name, too, so change it in the strings.xml resource file (the change will then reflect in the AndroidManifest.xml file, which is important): Before renaming: After renaming:   com.something.myapplication: Change the applicationID in the build.gradle (module level) file - the new name, derived from “My Renamed Application” will be without spaces, all lowercase, i.e. myrenamedapplication: Before changing: After changing: The yellowish bar will appear again near the top. Click the “Sync Now” in the right-hand part of it:           Now close the Android Studio, and rename the folder MyApplication (probably located in the folder C:\Users\someuser\AndroidStudioProjects\) to MyRenamedApplication (the name, derived from “My Renamed Application”, is without spaces). Although this step is optional, it is highly recommended to keep things tidy.

注意:

使用File→Open Recent打开重命名的项目当然会失败,所以在重命名后,第一次使用File→Open打开它。